除了在MySQL中,您不能使用。您可以使用NOT IN运算符来获得相同的结果。让我们首先创建一个表-
mysql> create table DemoTable1 ( Number1 int );Query OK, 0 rows affected (0.71 sec)
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable1 values(100);Query OK, 1 row affected (0.14 sec)mysql> insert into DemoTable1 values(200);Query OK, 1 row affected (0.13 sec)mysql> insert into DemoTable1 values(300);Query OK, 1 row affected (0.13 sec)
使用select语句显示表中的所有记录:
mysql> select *from DemoTable1
这将产生以下输出-
+---------+ | Number1 | +---------+ | 100 | | 200 | | 300 | +---------+ 3 rows in set (0.00 sec)
以下是创建第二个表的查询-
mysql> create table DemoTable2 ( Number1 int );Query OK, 0 rows affected (0.52 sec)
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable2 values(100);Query OK, 1 row affected (0.17 sec)mysql> insert into DemoTable2 values(400);Query OK, 1 row affected (0.14 sec)mysql> insert into DemoTable2 values(300);Query OK, 1 row affected (0.11 sec)
使用select语句显示表中的所有记录-
mysql> select *from DemoTable2;
这将产生以下输出-
+---------+ | Number1 | +---------+ | 100 | | 400 | | 300 | +---------+ 3 rows in set (0.00 sec)
以下是查询,以了解如何使用NOT IN运算符代替-
mysql> select Number1 from DemoTable1where Number1 not in (SELECT Number1 FROM DemoTable2);
这将产生以下输出-
+---------+ | Number1 | +---------+ | 200 | +---------+ 1 row in set (0.04 sec)