Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a two tables
table1

id
1
2
3
4

Table2

id
1
2

I need to get the records which does nt match in two tables using joins not any other method.

The answer should be 3,4
Posted

Try:
SQL
SELECT ID FROM Table1 LEFT JOIN Table2 ON Table1.Id=Table2.Id WHERE Table2.Id IS NULL
 
Share this answer
 
Comments
sacraj 21-Aug-13 7:04am    
thanks for the work
SQL
SELECT * FROM Table2
EXCEPT
SELECT * FROM Table1
 
Share this answer
 
Comments
sacraj 21-Aug-13 7:04am    
thanks for the solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900