56,675
社区成员
发帖
与我相关
我的任务
分享
mysql> select * from a;
+------+
| id |
+------+
| 1 |
| 2 |
+------+
2 rows in set (0.00 sec)
mysql> select * from b;
+------+---------+
| aid | content |
+------+---------+
| 1 | asss |
| 1 | sf |
| 2 | 示范法 |
| 2 | 不被 |
+------+---------+
4 rows in set (0.00 sec)
mysql> select
-> case when
-> (select count(*) from b where aid=t.aid and content<t.content)=0
-> then a.id end as id,
-> t.content
-> from a inner join b t on a.id=t.aid;
+------+---------+
| id | content |
+------+---------+
| 1 | asss |
| NULL | sf |
| 2 | 示范法 |
| NULL | 不被 |
+------+---------+
4 rows in set (0.00 sec)
mysql>