need join query
-
Tuesday, March 06, 2012 12:41 PMtable1 and table2
id id
1 3
2 4
3
4
select the records which are in table1 not in table2 by using joinNaresh
All Replies
-
Tuesday, March 06, 2012 12:44 PM
Pls try
select t1.* from table1 t1 left join table2 t2 on t1.id=t2.id where t2.id is null or select * from table1 where not exists(select 1 from table2 where table1.id=table2.id)
vt
Please mark answered if I've answered your question and vote for it as helpful to help other user's find a solution quicker
- Edited by v.vtMicrosoft Community Contributor Tuesday, March 06, 2012 1:26 PM
-
Tuesday, March 06, 2012 1:25 PM
Hi Naresh,
Please see the example below along with query,
DECLARE @TABLE1 TABLE(ID INT) DECLARE @TABLE2 TABLE(ID INT) INSERT INTO @TABLE1 VALUES (1), (2) , (3) , (4) INSERT INTO @TABLE2 VALUES (3) , (4) SELECT TABLE1.ID --, TABLE2.ID FROM @TABLE1 TABLE1 LEFT OUTER JOIN @TABLE2 TABLE2 ON TABLE1.ID = TABLE2.ID WHERE TABLE2.ID IS NULL
Thanks,
Suresh
Please use Mark or Propose as Answer if my post solved your problem and use Vote As Helpful if a post was useful.- Marked As Answer by Naresh_a Tuesday, March 06, 2012 4:32 PM

