Click here to Skip to main content
15,884,353 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
Suppose i have a 2 table. table1 has data

id  name
1   a
2   b
3   c

But Table2 has data 

id  name
1   a
2   b
3   c
4   d
5   e

Now i want a query which return remaining data

id   name
4   d
5   e


If any one have an idea kindly suggest me.
Posted
Comments
Mas11 4-Dec-12 7:23am    
Hey guys i have solved this..

use this Query,
SQL
select * from table2
except
select * from table1

Happy Coding!
:)
 
Share this answer
 
select * from Table2 where
where not exists (select * from table1 where table1.ID = Table2.ID)
 
Share this answer
 
your looking at outer join query. TSQL: Outer joins[^]

SQL
select b.id, b.name
from table1 a right outer join table2 b
on a.id = b.id
where a.id is null
 
Share this answer
 
v2
Hey guys i have solved this.. I am using another column name here.

SQL
select distinct client from projects where client not in(select distinct projects.client from projects inner join
 clients on projects.client=clients.companyname)
 
Share this answer
 

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