By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,828 Members | 2,241 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,828 IT Pros & Developers. It's quick & easy.

comparing two tables

P: n/a
Hi all,
I have two tables that are not link. But their content are
interrelated. I want to find out what is in one table that is not in
the other and vice-versa. how can archieve this in c# or within the
database.
thanks

Aug 31 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
If the tables are in SQL then probably let the database do the hard work.

I assume that there is some common key between the two tables (identifier).
If you had two tables called T1 and T2 and ID was the common key then:

SELECT * FROM T1 WHERE T1.ID NOT IN (SELECT ID FROM T2)

Would return all of the records in T1 that are not in T2. Just swap the
table names above to invert this.

Would probably make sense to ensure that there was an index on the ID column
in each table to speed up the join.

HTH

- Andy

"MORALBAROMETER" <su******@gmail.comwrote in message
news:11**********************@74g2000cwt.googlegro ups.com...
Hi all,
I have two tables that are not link. But their content are
interrelated. I want to find out what is in one table that is not in
the other and vice-versa. how can archieve this in c# or within the
database.
thanks

Aug 31 '06 #2

P: n/a
It is not a C# issue,You can do it using a simple sql query,

Something like it:

Select * From T1 Where ID Not In (Select ID From T2)

"MORALBAROMETER" <su******@gmail.comwrote in message
news:11**********************@74g2000cwt.googlegro ups.com...
Hi all,
I have two tables that are not link. But their content are
interrelated. I want to find out what is in one table that is not in
the other and vice-versa. how can archieve this in c# or within the
database.
thanks

Aug 31 '06 #3

P: n/a
Thanks alot. The tables have not common key. their keys are dereived
from same table.
Andy Bates wrote:
If the tables are in SQL then probably let the database do the hard work.

I assume that there is some common key between the two tables (identifier).
If you had two tables called T1 and T2 and ID was the common key then:

SELECT * FROM T1 WHERE T1.ID NOT IN (SELECT ID FROM T2)

Would return all of the records in T1 that are not in T2. Just swap the
table names above to invert this.

Would probably make sense to ensure that there was an index on the ID column
in each table to speed up the join.

HTH

- Andy

"MORALBAROMETER" <su******@gmail.comwrote in message
news:11**********************@74g2000cwt.googlegro ups.com...
Hi all,
I have two tables that are not link. But their content are
interrelated. I want to find out what is in one table that is not in
the other and vice-versa. how can archieve this in c# or within the
database.
thanks
Aug 31 '06 #4

P: n/a
Thanks alot. The tables have not common key. their keys are dereived
from same table.
Saber S. (==@ ) wrote:
It is not a C# issue,You can do it using a simple sql query,

Something like it:

Select * From T1 Where ID Not In (Select ID From T2)

"MORALBAROMETER" <su******@gmail.comwrote in message
news:11**********************@74g2000cwt.googlegro ups.com...
Hi all,
I have two tables that are not link. But their content are
interrelated. I want to find out what is in one table that is not in
the other and vice-versa. how can archieve this in c# or within the
database.
thanks
Aug 31 '06 #5

P: n/a
Not sure I follow you; so what fields do the two tables have in common (or
how can they be linked via another table if necessary)?

- Andy

"MORALBAROMETER" <su******@gmail.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
Thanks alot. The tables have not common key. their keys are dereived
from same table.
Andy Bates wrote:
>If the tables are in SQL then probably let the database do the hard work.

I assume that there is some common key between the two tables
(identifier).
If you had two tables called T1 and T2 and ID was the common key then:

SELECT * FROM T1 WHERE T1.ID NOT IN (SELECT ID FROM T2)

Would return all of the records in T1 that are not in T2. Just swap the
table names above to invert this.

Would probably make sense to ensure that there was an index on the ID
column
in each table to speed up the join.

HTH

- Andy

"MORALBAROMETER" <su******@gmail.comwrote in message
news:11**********************@74g2000cwt.googlegr oups.com...
Hi all,
I have two tables that are not link. But their content are
interrelated. I want to find out what is in one table that is not in
the other and vice-versa. how can archieve this in c# or within the
database.
thanks

Aug 31 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.