mysql null和‘ ’

null

''是空字符            相当于在银行有账号,不过没钱

null是空              相当于在银行账号都没有


null比较需要用 is null 或者 is not null 判断


null遇见运算符 一律返回null  =null 或 !=null 等等一律返回null ,并且效率不高,所以建表时候一般都会有not null default '';


mysql> select goods_name from goods where goods_name is not null limit 3;

+--------------------+

| goods_name         |

+--------------------+

| KD876              | 

| htcN85原装充电器           | 

| 诺基亚原装5800耳机            | 

+--------------------+

3 rows in set (0.00 sec)


mysql> select goods_name from goods where goods_name is null ;

Empty set (0.00 sec)


null 遇见运算符 一律返回null

mysql> select goods_name from goods where goods_name=null ;

Empty set (0.00 sec)


mysql> select goods_name from goods where goods_name!=null ;

Empty set (0.00 sec)


你可能感兴趣的:(mysql)