mysql> select * from a
;
+—-+——+————–+
| id | name | descri |
+—-+——+————–+
| 1 | a1 | 我是第一个a1 |
| 2 | a2 | 我是第一个a2 |
| 3 | a3 | 我是a3 |
| 4 | a1 | 我是第二个a1 |
| 5 | a2 | 我是第二个a2 |
+—-+——+————–+
5 rows in set
mysql> select a1.* from a a1 right join (select 本文来源gao@daima#com搞(%代@#码@网&max(id) id from a group by name) a2 on a1.id = a2.id where a1
.id is not null;
+—-+——+————–+
| id | name | descri |
+—-+——+————–+
| 3 | a3 | 我是a3 |
| 4 | a1 | 我是第二个a1 |
| 5 | a2 | 我是第二个a2 |
+—-+——+————–+
3 rows in set