So I got a question from a developer today who was trying to
SELECT NULL values from a table. As I have been asked about this
many times in the past, I decided to write a little post about
it.
mysql> SHOW CREATE TABLE testing_null \G
*************************** 1. row
***************************
Table: testing_null
Create Table: CREATE TABLE `testing_null` (
`id` int(11) unsigned NOT NULL auto_increment,
`mycolumn` varchar(12) default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1 row in set (0.00 sec)
mysql> INSERT INTO testing_null (mycolumn) VALUES('ho'),
(NULL), (NULL);
Query OK, 3 rows affected (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> SELECT * FROM testing_null;
+----+----------+
| id | mycolumn |
+----+----------+
| 1 | ho | …