首頁  >  文章  >  資料庫  >  mysql null 和 ‘ ’

mysql null 和 ‘ ’

黄舟
黄舟原創
2017-01-16 13:07:181518瀏覽

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)

3 rows in set (0.00 sec)

遇見運算子一律回傳null

mysql> select goods_name from goods where goods_name is null ;
Empty set (0.00 sec)
mysql> select goods_name from goods where goods_name=null ;
Empty set (0.00 sec)

以上就是mysql null和' '的內容,更多相關內容請關注PHP中文網(m.sbmmt.com)!


陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn