- 論壇徽章:
- 9
|
5.0.22沒問題,也許是4.0還沒支持 not in嵌套子查詢吧吧
mysql> create table a (domain int);
Query OK, 0 rows affected (0.01 sec)
mysql> create table b (domain int);
Query OK, 0 rows affected (0.01 sec)
mysql> insert into a values(1),(2);
Query OK, 2 rows affected (0.00 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> insert into b values(1);
Query OK, 1 row affected (0.00 sec)
mysql> select * from a where domain not in (select domain from b);
+--------+
| domain |
+--------+
| 2 |
+--------+
1 row in set (0.00 sec) |
表連接查詢的話:
select a.* from a left join b on a.domain=b.domain where b.primary_key is null; |
|