-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
1
  • 5
    Hint: SELECT DISTINCT. Commented Feb 10, 2019 at 13:45

2 Answers 2

2

Use group by / distinct in sql.

$sql = "SELECT arrFlight FROM flights group by arrFlight";
Sign up to request clarification or add additional context in comments.

Comments

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";

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.