比较运算符和函数

[not] between   and   不在/在什么范围之内
[not] in ()           列在不在某个范围之内
is [not]  null        是否为空


//案例
//[not] between   and   不在/在什么范围之内
mysql> select 5 between 1 and 10;    //1在不在1~10之间
+--------------------+
| 5 between 1 and 10 |
+--------------------+
|                  1 |              //1表示肯定,0表示否定
+--------------------+
1 row in set (0.37 sec)

mysql> select 50 between 1 and 10;
+---------------------+
| 50 between 1 and 10 |
+---------------------+
|                   0 |
+---------------------+
1 row in set (0.00 sec)


//[not] in ()  列在不在某个范围之内
mysql> select 50 in (1,25,50,75);
+--------------------+
| 50 in (1,25,50,75) |
+--------------------+
|                  1 |
+--------------------+
1 row in set (0.01 sec)


//is [not]  null  是否为空
mysql> select * from test where name is null;   //is null
+------+------+
| name | age  |
+------+------+
| NULL |    2 |
+------+------+
1 row in set (0.00 sec)

mysql> select * from test where name is not null;   //name is not null
+----------+------+
| name     | age  |
+----------+------+
| xiaodeng |   29 |
| erzi     |    1 |
|          | NULL |
+----------+------+
3 rows in set (0.00 sec)

 

posted @ 2016-10-30 13:58  Xiao|Deng  阅读(248)  评论(0编辑  收藏  举报