INSERT INTO tasks(title,completed)
VALUES('Master MySQL Boolean type',true),
('Design database table',false);
SELECT
id, title, completed
FROM
tasks;
+----+---------------------------+-----------+
| id | title | completed |
+----+---------------------------+-----------+
| 1 | Master MySQL Boolean type | 1 |
| 2 | Design database table | 0 |
+----+---------------------------+-----------+
2 rows in set
INSERT INTO tasks(title,completed)
VALUES('Test Boolean with a number',2);
mysql> SELECT
id, title, completed
FROM
tasks;
+----+----------------------------+-----------+
| id | title | completed |
+----+----------------------------+-----------+
| 1 | Master MySQL Boolean type | 1 |
| 2 | Design database table | 0 |
| 3 | Test Boolean with a number | 2 |
+----+----------------------------+-----------+
3 rows in set
SELECT
id,
title,
IF(completed, 'true', 'false') completed
FROM
tasks;
+----+----------------------------+-----------+
| id | title | completed |
+----+----------------------------+-----------+
| 1 | Master MySQL Boolean type | true |
| 2 | Design database table | false |
| 3 | Test Boolean with a number | true |
+----+----------------------------+-----------+
3 rows in set
SELECT
id, title, completed
FROM
tasks
WHERE
completed = TRUE;
+----+---------------------------+-----------+
| id | title | completed |
+----+---------------------------+-----------+
| 1 | Master MySQL Boolean type | 1 |
+----+---------------------------+-----------+
1 row in set
SELECT
id, title, completed
FROM
tasks
WHERE
completed IS TRUE;
+----+----------------------------+-----------+
| id | title | completed |
+----+----------------------------+-----------+
| 1 | Master MySQL Boolean type | 1 |
| 3 | Test Boolean with a number | 2 |
+----+----------------------------+-----------+
2 rows in set
SELECT
id, title, completed
FROM
tasks
WHERE
completed IS NOT TRUE;
+----+-----------------------+-----------+
| id | title | completed |
+----+-----------------------+-----------+
| 2 | Design database table | 0 |
+----+-----------------------+-----------+
1 row in set