mysql中is null语句的用法分享

2019-01-03 18:27:46王冬梅

mysql>
mysql> drop table topic;
query ok, 0 rows affected (0.00 sec)

 <=>null: null不等空
null意味着“没有值”或www.3ppt.com“未知值”,且它被看作与众不同的值。为了测试null,你不能使用算术比较 操作符例如=、<或!=
mysql>
mysql> select name, department, category
    -> from topic
    -> where category<=>null
    -> order by name;
empty set (0.00 sec)

mysql>
mysql> drop table topic;
query ok, 0 rows affected (0.02 sec)

is not null


mysql> select name, department, category
    -> from topic
    -> where category is not null
    -> order by name;
+----------------+------------+----------+
| name           | department | category |
+----------------+------------+----------+
| asp.net        | popular    | country  |
| c              | classical  | dance    |
| c sharp        | popular    | jazz     |
| c++            | classical  | general  |
| java           | popular    | rock     |
| javascript     | classical  | opera    |
| oracle         | classical  | general  |
| perl           | classical  | vocal    |
| php            | popular    | jazz     |
| pl/sql         | classical  | opera    |
| python         | popular    | blues    |
| sql server     | classical  | general  |
| uml            | classical  | general  |
| vb.net         | popular    | new age  |
| vc.net         | popular    | new age  |
| www.java2s.com | classical  | dance    |
+----------------+------------+----------+
16 rows in set (0.00 sec)

mysql>
mysql> drop table topic;
query ok, 0 rows affected (0.00 sec)

您可能感兴趣的文章:

MySQL查询空字段或非空字段(is null和not null)MySQL中对于NULL值的理解和使用教程详解MySQL中的NULL值mysql 中存在null和空时创建唯一索引的方法MySQL Left JOIN时指定NULL列返回特定值详解浅谈SQLServer的ISNULL函数与Mysql的IFNULL函数用法详解mysql中IFNULL,IF,CASE的区别介绍SQL Server、Oracle和MySQL判断NULL的方法mysql not in、left join、IS NULL、NOT EXISTS 效率问题记录mysql中将null值转换为0的语句MySQL NULL 值处理实例详解