MySQL IN和NOT IN关键字
mysql> select * from student;
+------+------+-----------+
| age | name | address |
+------+------+-----------+
| 12 | Jack | BeiJing |
| 19 | Mike | TianJin |
| 21 | Rose | ZhuHai |
| 23 | Ann | ShangHai |
| 27 | Alis | ShenZhen |
| 55 | Make | GuangZhou |
+------+------+-----------+
6 rows in set (0.00 sec)
mysql>
# in表示在集合中查找
mysql> select * from student where age in(19, 20, 23); +------+------+----------+ | age | name | address | +------+------+----------+ | 19 | Mike | TianJin | | 23 | Ann | ShangHai | +------+------+----------+ 2 rows in set (0.08 sec)
# not in表示不在集合中 mysql> select * from student where age not in(19, 20, 23); +------+------+-----------+ | age | name | address | +------+------+-----------+ | 12 | Jack | BeiJing | | 21 | Rose | ZhuHai | | 27 | Alis | ShenZhen | | 55 | Make | GuangZhou | +------+------+-----------+ 4 rows in set (0.00 sec) mysql>