Click here to Skip to main content
15,909,898 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi
How Comparing data in two different tables to find different record ?
Posted
Comments
nagendrathecoder 25-Apr-11 3:17am    
Your question is not clear, can you explain it little bit more.

Why would you want to do that?

In order to have any chance of doing it automatically, the two tables would have to have identical definitions: every field in both tables must be exactly the same.

So why would you have two tables which are the same, and contain the same information?

You can try something along the lines of:
SQL
SELECT * FROM table1 WHERE NOT EXISTS (SELECT * FROM table2 WHERE table1.Id = table2.Id)
 
Share this answer
 
Comments
raheleh_es 26-Apr-11 0:00am    
I have two tables that they have one fild to join
I need independence part of first table;
OriginalGriff 26-Apr-11 1:58am    
Sorry? That doesn't make a lot of sense - can you try again, but try an example: it may may it easier to work out what you are trying to say!
raheleh_es 26-Apr-11 3:54am    
select table1.* from table1,table2 where table1.Id!=table2.Id

but It repeted again
OriginalGriff 26-Apr-11 4:27am    
Yes, it will. You have asked for "all records in these two tables which do not have the same iD".
i.e.: if table1 has records with iD 1, 2, 3, and table2 has records with iDs 1, 2, 3 then return:
1 2,
1 3,
2 1,
2 3,
3 1,
3 2
but not
1 1,
2 2,
3 3

Did you try what I suggested?
raheleh_es 26-Apr-11 5:40am    
yes

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