-1

I have an my SQL database like this:

id | name | birth_date
1 | John | 20-03-2000
2 | Dani | 20-03-2000
3 | Julia | 19-12-1999
4 | Martin | 12-08-2001
5 | May | 19-12-1999

.....

How can I get:

20-03-2000
John
Dani

19-12-1999
Julia
May

12-08-2001
Martin

Thank you

Bira
  • 4,531
  • 2
  • 27
  • 42
May Tin
  • 43
  • 4
  • 4
    Hello, welcome to Stack Overflow. To get the most out of the site, it is important to post any code you have written to try to solve the problem. Please post any code you have tried here. – Russ J Mar 13 '19 at 02:39
  • 1
    It's much easier to query the data from the database then re-arrange the structure using PHP than using SQL alone. –  Mar 13 '19 at 02:52
  • 1
    just order by date, and check where the date changes as you loop the results. –  Mar 13 '19 at 02:56
  • Yep, this kind of task is best resolved in application code – Strawberry Mar 13 '19 at 08:38

1 Answers1

0

SELECT * FROM table ORDER BY birth_date desc

returns

id | name | birth_date 1 | John | 20-03-2000 2 | Dani | 20-03-2000 3 | Julia | 19-12-1999 5 | May | 19-12-1999 4 | Martin | 12-08-2001

to render what you want do it on php

OR you can try GROUP CONCAT here is a link GROUP CONCAT

Nyuu
  • 65
  • 1
  • 8