dcount_tbl
新增兩筆紀錄且其 dyw_count
都是空的值。
[root@kvm8 ~]# mysql -s -uroot -p123qwe mysql> use dyw; mysql> insert into dcount_tbl(dyw_author,dyw_count) -> values -> ('jenny', null), -> ('sara',null) -> ;
dcount_tbl
中欄位 dyw_count
是空的紀錄,
不能使用運算子 =, !=
。
mysql> select * from dcount_tbl where dyw_count = null; mysql> select * from dcount_tbl where dyw_count != null;
dcount_tbl
中欄位 dyw_count
是空的紀錄,必須使用 IS NULL, IS NOT NULL
等語法。
mysql> select * from dcount_tbl where dyw_count is null; dyw_author dyw_count jenny NULL sara NULL mysql> select * from dcount_tbl where dyw_count is not null; dyw_author dyw_count dywang 4 linda 3 peter 2 rita 1
<=>
運算子等效 IS NULL
語法。
mysql> select * from dcount_tbl where dyw_count <=> null; dyw_author dyw_count jenny NULL sara NULL