MariaDB root@(none):dyw> insert into dcount(author,dcount) values('jenny',null),(
-> 'sara',null);
Query OK, 2 rows affected
Time: 0.089s
MariaDB root@(none):dyw> select * from dcount; +--------+--------+ | author | dcount | +--------+--------+ | dywang | 4 | | linda | 3 | | peter | 2 | | rita | 1 | | jenny | <null> | | sara | <null> | +--------+--------+ 6 rows in set Time: 0.024s
=, !=。
mariadb> select * from tablename where field = null; mariadb> select * from tablename where field != null;
IS NULL 查詢資料表 dcount 中欄位 dcount 是空的紀錄。
MariaDB root@(none):dyw> select * from dcount where dcount is null; +--------+--------+ | author | dcount | +--------+--------+ | jenny | <null> | | sara | <null> | +--------+--------+ 2 rows in set Time: 0.057s
IS NOT NULL 查詢資料表 dcount 中欄位 dcount 不是空的紀錄
MariaDB root@(none):dyw> select * from dcount where dcount is not null; +--------+--------+ | author | dcount | +--------+--------+ | dywang | 4 | | linda | 3 | | peter | 2 | | rita | 1 | +--------+--------+ 4 rows in set Time: 0.028s
<=> 運算子等效 IS NULL 語法。
MariaDB root@(none):dyw> select * from dcount where dcount <=> null; +--------+--------+ | author | dcount | +--------+--------+ | jenny | <null> | | sara | <null> | +--------+--------+ 2 rows in set Time: 0.028s