范围内匹配/去重显示
匹配范围内的任意一个值即可
in (值列表) 在...里...
not in (值列表) 不在...里...
between 数字1 and 数字2 在...之间...
distinct 字段名 去重显示(去掉重复的,只显示一次) distinct(不同的)
mysql> select name from user where name in ("daemo","adm","root","bob"); 字符要用引号""引起来
+------+
| name |
+------+
| root |
| adm |
| bob |
+------+
mysql> select name from user where uid in (10,20,30,40,50);
Empty set (0.00 sec)
mysql> select name from user where uid in (1,7,3,40,50);
+------+
| name |
+------+
| bin |
| adm |
| halt |
+------+
mysql> select name,shell from user
-> where
-> shell not in ("/bin/bash","/sbin/nologin"); 是not in,而不是is not in。要和is null(是空),is not null(非空)的使用区分开来。
mysql> select * from user
-> where
-> id between 10 and 20;
mysql> select shell from user;
mysql> select distinct shell from user; distinct,后面是字段就行了
+----------------+
| shell |
+----------------+
| /bin/bash |
| /sbin/nologin |
| /bin/sync |
| /sbin/shutdown |
| /sbin/halt |
| /bin/false |
+----------------+