jeudi 13 août 2015

MYSQL Order By after GROUP by not working

mysql> select manga_source_id,manga_episode_name,manga_episode_number from manga_chapter;
+-----------------+--------------------------------------+----------------------+
| manga_source_id | manga_episode_name                   | manga_episode_number |
+-----------------+--------------------------------------+----------------------+
|               5 | A Method to Make the World Gentle 1  |                    1 |
|               5 | A Method to Make the World Gentle 2  |                    2 |
|               5 | A Method to Make the World Gentle 3  |                    3 |
|               5 | A Method to Make the World Gentle 5  |                    5 |
|               5 | A Method to Make the World Gentle 6  |                    6 |
|               5 | A Method to Make the World Gentle 7  |                    7 |
|               5 | A Method to Make the World Gentle 8  |                    8 |
|               5 | A Method to Make the World Gentle 9  |                    9 |
|               5 | A Method to Make the World Gentle 10 |                   10 |
|               5 | A Method to Make the World Gentle 11 |                   11 |
|               5 | A Method to Make the World Gentle 12 |                   12 |
|               5 | A Method to Make the World Gentle 13 |                   13 |
|               5 | A Method to Make the World Gentle 14 |                   14 |
|               5 | A Method to Make the World Gentle 15 |                   15 |
|               5 | A Method to Make the World Gentle 16 |                   16 |
|               5 | A Method to Make the World Gentle 17 |                   17 |
|               5 | A Method to Make the World Gentle 18 |                   18 |
|               5 | A Method to Make the World Gentle 19 |                   19 |
|               5 | A Method to Make the World Gentle 20 |                   20 |
|               5 | A Method to Make the World Gentle 21 |                   21 |
|               5 | A Method to Make the World Gentle 22 |                   22 |
|               5 | A Method to Make the World Gentle 23 |                   23 |
|               5 | A Method to Make the World Gentle 24 |                   24 |
|               5 | A Method to Make the World Gentle 25 |                   25 |
|               5 | A Method to Make the World Gentle 26 |                   26 |
+-----------------+--------------------------------------+----------------------+
25 rows in set (0.00 sec)

mysql> select manga_source_id,manga_episode_name,manga_episode_number from manga_chapter GROUP by manga_source_id ORDER BY manga_episode_number DESC;
+-----------------+-------------------------------------+----------------------+
| manga_source_id | manga_episode_name                  | manga_episode_number |
+-----------------+-------------------------------------+----------------------+
|               5 | A Method to Make the World Gentle 1 |                    1 |
+-----------------+-------------------------------------+----------------------+

I tried to get the last manga_episode_number which is A Method to make the world gentle 26 however it doesn't work, even I specify ORDER by manga_episode_number DESC

How can I achieve drawing that last record, with GROUP by

thanks!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire