Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 not in not getting results

Author  Topic 

tpiazza55
Posting Yak Master

162 Posts

Posted - 2008-11-17 : 16:18:56
i am trying to write a query that will allow me to get email addresses from an temp table that arent in my main table

sql below will give me the ones that are in the table is i use "in" but will not get me the email that are not in the table when I use "not in"

what am i doing wrong -- both are varchar(100)

SELECT email
FROM temp_email
where email not IN

(

SELECT email
FROM tblUser
)

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-11-17 : 16:26:01
NOT IN is not the opposite of IN, regarding NULL values.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

tpiazza55
Posting Yak Master

162 Posts

Posted - 2008-11-17 : 16:31:03
kicked the nulls out and it worked thanks
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2008-11-18 : 04:49:38
SELECT t1.emailid
FROM temp_email t1
inner join
tblUser AS t ON t.emailid NOT LIKE t1.emailid Group by t1.emailid having count(t1.emailid) > 1
Go to Top of Page
   

- Advertisement -