2
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)
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 |
+-----------------+-------------------------------------+----------------------+
組之後,我試圖獲得最後manga_episode_number這是 一種方法,讓世界溫柔26但它不工作,即使我通過manga_episode_number DESC指定ORDERMYSQL順序按由不工作
如何才能實現繪製最後一條記錄,用GROUP
謝謝!
你不需要通過,'選擇manga_source_id,manga_episode_name,manga_episode_number從manga_chapter順序GROUP BY manga_episode_number DESC LIMIT 1;' –
@JorgeCampos我的,因爲我將有另一行需要組不同的記錄rent manga_source_id,我只是想畫出最高的manga_episode_number的每個manga_source_id的1條記錄 –
你需要這個名字嗎? 'manga_episode_name'? –