Internally in MySQL there are no bool values. Expressions that appear to return boolean values ββactually return an integer of 0 or 1:
SELECT (3 < 5) 1 SELECT (3 > 5) 0 SELECT (3 < 4) + (4 < 5) 2 SELECT TRUE 1
TRUE and FALSE are just aliases for 1 and 0.
NULL is not equal to any value, not even another NULL.
SELECT NULL = '' NULL SELECT NULL = NULL NULL
If you want to compare with NULL, use IS NULL .
Update: There was some confusion about whether MySQL supports a boolean value. This example shows that even the BOOL type in the column is still an integer:
CREATE TABLE table1 (id INT, x BOOL);
INSERT INTO table1 VALUES
(1, TRUE),
(2, false),
(3, 3); - Can you insert 3 into a BOOL type? Yep!
SELECT * FROM TABLE1;
Results:
id x 1 1 2 0 3 3
source share