To NULL or NOT to NULL that is the question.

January 27, 2012

I liked Shlomi Noach post on “IS TRUE and IS FALSE“.  This kind of logic create bugs.

What will this return?

select if((1 = true) and ( 1 is TRUE) and (NULL is not TRUE), TRUE, FALSE) as answer;

You should know,

NULL is never TRUE or FALSE but


NULL is a little like a vacuum.  Ancient Greek philosophers did not like to admit the existence of a vacuum, asking themselves “how can ‘nothing’ be something?”.    Does GOD exist in NULL?

If  select “” is NOT NULL; is TRUE what is “”?

select "" is NOT NULL;
| "" is NOT NULL |
|              1 |

Is the lack of an answer, an answer? Is the lack of datum, DATA?  Or should it be “”.  Should we record the blank spaces?


Create Table
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`data` varchar(16) DEFAULT NULL,
KEY `id` (`id`)

When should this happen?

for x = 1 to X;
INSERT INTO `test`(`data`) VALUES ( NULL);
next x;

Null happens.

posted in Commentary by mark

Follow comments via the RSS Feed | Leave a comment | Trackback URL

Leave Your Comment

You must be logged in to post a comment.


Powered by Wordpress and MySQL. Theme by Shlomi Noach,
Creative Commons License
MySQL Fan Boy by Mark Grennan is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.