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

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

人生于世,就得有点兴致,闲暇之时,或乐游山水、或尽享食味、或寄情岁时,它让我们的生活变得充盈。

评论

^