From: Martijn Tonies Date: September 19 2005 7:25am Subject: Re: Yet another null question List-Archive: http://lists.mysql.com/mysql/189251 Message-Id: <00e101c5bceb$4349e5a0$c802a8c0@martijnws> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Hello Doug, > My question question from MySQL 4.0.22: is it okay that a null interger tests as > equal to any value. I am not sure the table structure matters but in case it is > I included it. > > I did not expect that null was not not-equal to 1. Cursory testing seems to > indicate that a null integer field is not not-equal to any specific value. If > this is the "known" behavior, I would suggest that this behavior be added to > section A.5.3. Testing the field=1 works as I would expect, that is the null > value is not equal to 1. That's because NULL is NOT a value (not the logical "not" ;) ... It's a state. Any column can have two states: either NULL or NOT NULL. When a column is "not null" it can have values suitable for it's given domain (eg: all integer values). If there's no value (NULL), how can you compare it? Think of "NULL" as "unknown". Is 2 equal to "unknown"? I don't know, so the result is "unknown", hence, NULL. Hope this helps, With regards, Martijn Tonies Database Workbench - tool for InterBase, Firebird, MySQL, Oracle & MS SQL Server Upscene Productions http://www.upscene.com Database development questions? Check the forum! http://www.databasedevelopmentforum.com