-1

How to retrieve one time the arrival date of flight from a table even if other rows has the same date. Here my code

$sql = "SELECT arrFlight FROM flights";
$ data = mysqli_query($conn, $sql);
foreach($data as $date){
echo $date['arrFlight'] . </br>;
}

Here is the response

2019-02-20

2019-02-20

2019-01-18

2019-01-18

2019-02-10

2019-02-01

2019-01-21

2019-01-21

2019-02-18

2019-01-18

2019-02-05

Now how can I retrieve only one time the dates that has same value?

2019-02-20

2019-01-18

2019-02-10

2019-02-01

2019-01-21

2019-02-05
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107
carlo
  • 23
  • 3

2 Answers2

2

Use group by / distinct in sql.

$sql = "SELECT arrFlight FROM flights group by arrFlight";
Gaurav
  • 1,070
  • 9
  • 11
1

Try this query

$sql = "SELECT DISTINCT  arrFlight FROM flights";

OR

 $sql = "SELECT arrFlight FROM flights GROUP BY arrFlight";

Rather then

$sql = "SELECT arrFlight FROM flights";
Zahid Hassan Shaikot
  • 1,066
  • 10
  • 18