空字符串为: =''null值则为: where field_name is (not) null 或 ifnull(field_name,'')=''
SELECT * FROMM TB WHERE 字段 IS NULL OR 字段='' OR LOWER(字段)=LOWER('NULL')
select * from yourTable where col is null;mysql> select * from t_asoliddream66; +------+------+ | id | col | +------+------+ | 1 | NULL | | 2 | aaa | | 3 | NULL | | 4 | bbb | +------+------+ 4 rows in set (0.05 sec)mysql> select * from t_asoliddream66 where col is null; +------+------+ | id | col | +------+------+ | 1 | NULL | | 3 | NULL | +------+------+ 2 rows in set (0.08 sec)mysql>
不知道这有没有影响
is null而不是用=
+------+------+
| id | col |
+------+------+
| 1 | NULL |
| 2 | aaa |
| 3 | NULL |
| 4 | bbb |
+------+------+
4 rows in set (0.05 sec)mysql> select * from t_asoliddream66 where col is null;
+------+------+
| id | col |
+------+------+
| 1 | NULL |
| 3 | NULL |
+------+------+
2 rows in set (0.08 sec)mysql>