Skip to main content

Timeline for SQL: empty string vs NULL value

Current License: CC BY-SA 2.5

9 events
when toggle format what by license comment
Aug 13, 2012 at 22:00 comment added Izkata @Ramhound NULL means there is no value. A person without a middle name has no value there. Therefore, NULL should be used in a middle initial column as well... Which is completely opposite the argument presented in this answer.
Aug 9, 2012 at 19:08 comment added Alexey @Ramhound, i agree that the empty string is a value, and that NULL vaguely means "there is no value". I just explained my interpretation of "no value". In my opinion, it is not the same as "the person has not opened any email account". It is rather "no email address recorded for that person".
Aug 9, 2012 at 11:43 comment added Ramhound @Alexey - NULL means there is no value. As others have pointed out an empty string is a value.
Aug 8, 2012 at 9:28 comment added Alexey I think NULL does not mean that there is no email address, i think it means that the email address is currently not known, not known to exist, or is impossible to fill in for other reasons. Fortunately, the is probably no situation where one would want to keep in a database the information about people who truly do not have and do not plan to have any email address, otherwise a separate boolean field would probably be necessary.
Sep 29, 2011 at 17:52 comment added Martijn being pedantic, I guess SELECT COUNT(EMAIL) FROM YOURTABLE makes more sense here
Jan 4, 2011 at 8:46 vote accept Jacek Prucia
Dec 30, 2010 at 14:03 comment added LudoMC Totally agree. NULL is there for a reason. SELECT COUNT(*) FROM YOURTABLE WHERE EMAIL IS [NOT] NULL is the way to do it, not string comparison which will tend to be slower (even for empty strings I suppose but I'm not sure of this one :).
Dec 30, 2010 at 12:32 comment added Philippe I was writing the same answer, but not as well written :)
Dec 30, 2010 at 12:22 history answered Dean Harding CC BY-SA 2.5