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

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 自连接

日子过着过着就有了答案,努力走着走着就有了温柔的着落。

评论

^