I would use something like this:

SELECT DISTINCT T1.EmailAddress
FROM Table1 T1
WHERE NOT EXISTS (SELECT 1 FROM Table2 WHERE Email = T1.EmailAddress)

NOT EXISTS performs pretty quickly as it only checks that it would exist.

Ben Miller


----- Original Message ----- 
From: "sas0riza" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, June 22, 2005 12:07 PM
Subject: [AspNetAnyQuestionIsOk] Column Comparison


> Hello,
> 
> What is the best way to compare 2 columns in 2 different tables?
> 
> For instance, both tables have an email column. Table1 has all the 
> email addresses, while Table2 holds only the email addresses that 
> have replied or completed a form. I want to compare the two and 
> return a list of email addresses that haven't replied or completed a 
> form yet.
> 
> This is what I have, but I'm not sure if it is the proper way:
> 
> SELECT Distinct [EmailAddress]  
> FROM [db].[dbo].[Table1], [db].[dbo].[Table2]
> where [EmailAddress] not like [Email]
> GO
> 
> 
> Note: Table1 has the column EmailAddress and Table2 has the column 
> Email.
> 
> It seems to work, but for some reason, I would still get some email 
> addresses returned even though a response was received from them.
> 
> Any help is greatly appreciated.
> 
> Thanks!
> 
> 
> 
> 
> 
> 
> Yahoo! Groups Links
> 
> 
> 
> 
> 
> 
>


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to