Home > Database > Mysql Tutorial > mysql null和' '

mysql null和' '

黄舟
Release: 2017-01-16 13:07:18
Original
1762 people have browsed it

null
'' is an empty character, which is equivalent to having an account in the bank, but no money.
null is empty, which is equivalent to not having an account in the bank.

To compare null, you need to use is null or is not Null judgment

When null encounters an operator, it will always return null. =null or!=null, etc. will all return null, and the efficiency is not high, so when creating a table, there will usually be not null default '';

mysql> select goods_name from goods where goods_name is not null limit 3;
+--------------------+
| goods_name |
+--------------------+
| KD876 | 
| htcN85原装充电器 | 
| 诺基亚原装5800耳机 | 
+--------------------+
Copy after login

3 rows in set (0.00 sec)

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

null will return null when encountering the operator

mysql> select goods_name from goods where goods_name=null ;
Empty set (0.00 sec)
Copy after login
mysql> select goods_name from goods where goods_name!=null ;
Empty set (0.00 sec)
Copy after login

The above is mysql null and ' ' content, please pay attention to the PHP Chinese website (www.php.cn) for more related content!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template