Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query to compare 2 tables

Status
Not open for further replies.
May 11, 2004
37
US
I have 2 small tables (one column) that contain email addresses. I want to compare the tables to find out which email addresses match up between the 2 tables. Is there a simple way to query for this?

Thanks,

Rich
 
Join the tables on emailaddresses:
Code:
select a.emailaddress, 
       b.emailaddress
from   tableA a 
       inner join TableB b 
       on (a.Emailaddress = b.EmailAddress)

Regards,
AA
 
Code:
SELECT Table1.EMail, Table2.EMail FROM Table1
LEFT JOIN Table2 ON Table1.eMail = Table2.eMail
WHERE NOT Table2.eMail IS NULL
(not tested)

Borislav Borissov
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top