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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Query Help

Author  Topic 

jscot
Posting Yak Master

106 Posts

Posted - 2011-06-18 : 00:29:26
Here is my sample table

Table A

ID CID OID
1 23 56
2 45 21
3 44 33

Table B

ID CID OID
1 23 56
2 44 33

Here is my question, How i can find out OID don't have in Table B.

I know one way i can do to find out which Oid don't have in Table B is
NOT IN syntax,
Is there other way ?

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-06-18 : 06:31:54
Are you running into any performance or other problems with using "NOT IN"? In any case, another alternative would be to use a left join as in:

select
a.*
from
a
left join b on
a.oid = b.oid
where
b.oid is null
Go to Top of Page
   

- Advertisement -