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>

 

posted @ 2013-05-02 11:55  robotke1  阅读(328)  评论(0编辑  收藏  举报