"leegold" <[EMAIL PROTECTED]> wrote on 03/29/2005 04:58:11 PM:
> Hi, > > I understand that we should use "IS" instead of "=" for selecting fields > with NULL. But then, shouldn't the statement below cause a syntax error? > Please explain. > > select * from test2 where datecurrent=NULL; > > Thanks, > Lee Nope Because the result of comparing anything to null is null, your test query evaluates to: select * from test2 where null and "WHERE NULL" evaluates to FALSE (because of handling subqueries that return no rows) so that you never ever get any rows. At least it didn't throw any errors on my test server (4.1.1a-alpha-nt) To allow the comparison of null to null to be true, MySQL created the comparitor <=>. anyvalue<=>null is false(0) null<=>null is true(1) Shawn Green Database Administrator Unimin Corporation - Spruce Pine