homepage Welcome to WebmasterWorld Guest from 54.227.171.163
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

    
Display results from 2 tables filtering same results
gbdj



 
Msg#: 4307366 posted 3:25 pm on May 3, 2011 (gmt 0)

Hi,

This is probably very easy but I seem to be struggling on this so hopefully some body can help.

I am trying to display results from field 'email' in table1, When I display the results I don't want table1.email to appear if it exists in table2.email.

So far I have tried these 2 statements:
SELECT test1.email FROM test1, test2 WHERE (test1.email != test2.email)

and

SELECT test1.email FROM test1 LEFT JOIN test2 ON test2.email = test2.email WHERE (test1.email != test2.email)

Neither Worked

Hopefully somebody can help me out.

Thanks

 

mark_roach

10+ Year Member



 
Msg#: 4307366 posted 3:31 pm on May 3, 2011 (gmt 0)

select email from table1 where email not in (select email from table2)

gbdj



 
Msg#: 4307366 posted 3:37 pm on May 3, 2011 (gmt 0)

that was tooo easy!

Thanks for your help

Final Query:
SELECT email FROM test1 WHERE email NOT IN (SELECT EMAIL FROM test2)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved