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.
Author |
Topic |
SCHEMA
Posting Yak Master
192 Posts |
Posted - 2009-03-26 : 11:44:57
|
I have 2 tables1) Table1 id subid1 11 21 31 52) Table 2id subid1 13 54 6Tables don't have PK. If records exist in table1 for table 2,I want to exclude. |
|
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts |
Posted - 2009-03-26 : 13:41:56
|
Not sure what you want. May be this,select * from table2 a2 where not exists ( select * from table1 a1 where a1.id=a2.id and a1.subid=a2.subid ) |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-03-29 : 02:38:35
|
try this tooSELECT a2.* FROM table2 a2 LEFT JOIN table1 a1 ON a1.id=a2.id AND a1.subid=a2.subidWHERE a1.id IS NULL |
|
|
|
|
|