Hi All, This query worked for me.
SELECT a.address FROM a LEFT JOIN b ON a.id != b.iid AND b.message='y' Thanks, Harish -----Original Message----- From: Michael Stassen [mailto:[EMAIL PROTECTED] Sent: Monday, January 31, 2005 12:23 AM To: Roger Baklund Cc: mysql; Harish Subject: Re: Need a query to get the difference of two tables Roger Baklund wrote: > Harish wrote: > >> Hi, >> >> I apprecaite anybody replying me with an equvalent query for this: >> I am using mysql 4.0.21 >> >> >> select a.address from a where a.id not in (select b.iid from b where >> b.message='y') > > > This can be done with a left join: > > select a.address > from a > left join b on b.iid=a.id > where b.iid is null; That's not equivalent, because it leaves out a condition. I think it should be SELECT a.address FROM a LEFT JOIN b ON a.id = b.iid AND b.message='y' WHERE b.iid IS NULL; Michael -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]