I have a preliminary MYSQL question, but I would like to group them in title when there is a table like the one below and list them in order of new date.
Could you tell me the SELECT statement at this time?
Thank you for your cooperation.
id title date
---------------------
1AAAA June 20, 2017
2BBBBBB June 19, 2017
3AAAA June 18, 2017
4CCCCCC June 17, 2017
5BBBBBB June 20, 2017
id title date
---------------------
1AAAA June 20, 2017
3AAAA June 18, 2017
5BBBBBB June 20, 2017
2BBBBBB June 19, 2017
4CCCCCC June 17, 2017
What you want to do is to put the same lines next to each other and arrange them in reverse order of the date? The former can also be sorted, so it would be better to sort by multiple conditions using ORDER BY
as follows:(ASC
represents ascending order and DESC
represents descending order, but ASC
in ascending order is optional.)
SELECT*
From...
ORDER BY TITLE ASC, date DESC;
(First of all, I think reading the introduction to SQL is the shortcut.)
© 2025 OneMinuteCode. All rights reserved.