Home » MySQL » In the MySQL <=> comparison operator

In the MySQL <=> comparison operator

in the MySQL query, if you want to filter out specific records, generally using = comparison operator, for example:


SELECT * FROM users WHERE name ''
= three

but when the need to extract name equal to NULL records, you cannot use the =:


SELECT * FROM users WHERE name = NULL

if the query is written so, find out anything, because in comparison with NULL basically has no meaning.


then query how to write
?
1) the first method


SELECT * FROM users WHERE name NULL
<=>

2)

second method
SELECT * FROM users WHERE name IS NULL

so the difference between <=> and = is that = can not be compared with the NULL, <=>.


but the above two methods, it is recommended to use the second, because the IS NULL (and IS NOT NULL) is a part of the ANSI standard, so it can also be used in other database. <=> can only use.

in MySQL

Latest