Since I recently wrote a paper on string fuzzy retrieval, we began to study the index problem in a more detailed database (MySQL), and changed to the library to borrow the effective MySQL SQL statement optimization (Ronald Bradford, Lishee). I saw it in there today. The unique key can contain null values, and each null value is unique (that is, the null! =null) ". The first reaction is: I go, what ghost? It's not a man's thing!! In fact, the computer industry a lot of such words, think and then went online to find write information!
Use the SQL SELECT command of the WHERE clause to get the data from the MySQL table. However, when we try to give a condition to compare the value of a field or column to NULL, it does not work correctly.
To handle this situation, MySQL provides three large operators
- Is null: This operator returns True when the value of the column is null.
- is not NULL: the operator returns True when the value of the column is not NULL.
- The <=> operator comparison value (unlike the = operator) is ture, even if two null values
The null condition involved is special. You cannot use =null or!=null to find a column with a NULL value. This comparison always tells them whether it is a real failure, because it is impossible. Even the null=null failed.
If you are looking for columns that are or are not NULL, use is NULL or is not NULL.
Reference documents:
1. Detailed explanation of null values in MySQL
2. are not null and!=null and NULL in MySQL
The unique key can contain null values, and each null value is unique (that is, the null! =null) "Understand