MySQL Forums
Forum List  »  Newbie

Re: Left joins on 2 tables to find results NOT in one...
Posted by: Felix Geerinckx
Date: May 09, 2005 08:31AM

waidat chan wrote:

> select table1.*,table2.customer_id
> from table1
> left join table2 on table1.data_id = table2.data_id
> where table2.customer_id is null or table2.customer_id <> 1;
>
> (To find all that customer_id = 1 has not commented on)

Untested:

select table1.*,table2.customer_id
from table1
left join table2 on table1.data_id = table2.data_id and table2.customer_id = 1
where table2.customer_id is null

--
felix
Please use BBCode to format your messages in this forum.

Options: ReplyQuote


Subject
Written By
Posted
Re: Left joins on 2 tables to find results NOT in one...
May 09, 2005 08:31AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.