The MySQL IS operator tests an expression against TRUE, FALSE, or UNKNOWN. In MySQL, zero is false, any nonzero non-NULL numeric value is true, and NULL represents unknown.
SELECT 1 IS TRUE, 0 IS FALSE, NULL IS UNKNOWN;
| 1 IS TRUE | 0 IS FALSE | NULL IS UNKNOWN |
|---|---|---|
| 1 | 1 | 1 |
The sample plus2_boolean table stores integer values. IS TRUE matches nonzero, non-NULL values.
SELECT * FROM `plus2_boolean` WHERE mar IS TRUE;
| name | jan | feb | mar |
|---|---|---|---|
| Alex | 1 | 0 | 1 |
| John | 1 | 0 | 2 |
| Lone | 1 | 1 | 4 |
| King | NULL | NULL | 1 |
SELECT * FROM `plus2_boolean` WHERE jan IS NOT TRUE;
Output:
| name | jan | feb | mar |
|---|---|---|---|
| Ronn | 0 | 1 | 0 |
| Raju | NULL | 1 | 0 |
| King | NULL | NULL | 1 |
IS NOT TRUE includes both false values and NULL values.
SELECT * FROM `plus2_boolean` WHERE jan IS UNKNOWN;
Output:
| name | jan | feb | mar |
|---|---|---|---|
| Raju | NULL | 1 | 0 |
| King | NULL | NULL | 1 |
IS UNKNOWN is true only when the expression is NULL. See also NULL handling and the comparison operators.
MySQL can coerce strings to numbers in Boolean contexts. That behavior is demonstrated below, but application queries should normally compare character data explicitly instead of depending on numeric coercion.
SELECT * FROM student3 WHERE class IS TRUE;
Output:
| id | name | class | mark |
|---|---|---|---|
| 7 | My John Rob | 5 | 5 |
A numeric-looking value such as '5' can evaluate as true after conversion.
SELECT * FROM student3 WHERE class IS FALSE;
Non-numeric text converts differently from meaningful Boolean data, which is why explicit comparisons are clearer.
SELECT * FROM student3 WHERE class IS UNKNOWN;
Output:
| id | name | class | mark |
|---|---|---|---|
| 2 | Max Ruin | NULL | 85 |
| 4 | Krish Star | NULL | NULL |
| 6 | Alex John | NULL | 55 |
This returns rows where class is NULL.
Checkbox matrix example using Boolean data
The original student3 SQL dump is retained below for testing.
For conditional output and NULL fallback, see IF(), COALESCE(), and CASE and summing multiple columns.
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.