From: Peter Brawley Date: January 4 2006 7:44pm Subject: Re: Can someone tell me why this fails? List-Archive: http://lists.mysql.com/mysql/193504 Message-Id: <43BC259F.40000@earthlink.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=======AVGMAIL-43BC259F67FF=======" --=======AVGMAIL-43BC259F67FF======= Content-Type: multipart/alternative; boundary=------------000301040706080405070704 --------------000301040706080405070704 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Ed, />Can someone tell me why this fails? I'm using v4.1.11 >Select IF(((Select 1+1) <> Null) and ((Select 1+1) <> 0), (Select 1+1), 'WRONG') >I would expect a result of 2. / NULL is neither equal nor unequal to anything including itself. To get the result you expect, write Select IF(((Select 1+1) IS NOT Null) and ((Select 1+1) <> 0), (Select 1+1), 'WRONG'); PB --------------000301040706080405070704 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Ed,

>Can someone tell me why this fails? I'm using v4.1.11
>Select IF(((Select 1+1) <> Null) and ((Select 1+1) <> 0), (Select 1+1), 'WRONG')
>I would expect a result of 2.

NULL is neither equal nor unequal to anything including itself.

To get the result you expect, write

Select IF(((Select 1+1) IS NOT Null) and ((Select 1+1) <> 0), (Select 1+1), 'WRONG');

PB
--------------000301040706080405070704-- --=======AVGMAIL-43BC259F67FF======= Content-Type: text/plain; x-avg=cert; charset=us-ascii Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Content-Description: "AVG certification" No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.371 / Virus Database: 267.14.12/220 - Release Date: 1/3/2006 --=======AVGMAIL-43BC259F67FF=======--