简体   繁体   中英

PHP - MySQL: How to select data grouping by date

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM