计算机网络/计算机科学与应用/系统/运维/开发

MySQL-自连接


mysql> select * from tb2 a where not exists (select 'x' from tb2 where gid=a.gid and col2>a.col2);
+----+------+------+------+
| id | gid  | col1 | col2 |
+----+------+------+------+
|  6 | A    |   29 |   97 |
| 15 | E    |   14 |   86 |
| 24 | D    |   54 |   79 |
| 28 | C    |   34 |   90 |
| 32 | B    |    4 |   90 |
+----+------+------+------+
5 rows in set (0.00 sec)


mysql 自连接

日子是崭新的,不要回头看,如果今年还掉眼泪,希望是喜极而泣。

评论

^