473,802 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

comparing two tables

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
5 1678
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.goog legroups.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
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.goog legroups.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
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.goog legroups.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
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.goog legroups.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
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.goo glegroups.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

"MORALBAROMETE R" <su******@gmail .comwrote in message
news:11******* *************** @74g2000cwt.goo glegroups.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

41
3969
by: Odd-R. | last post by:
I have to lists, A and B, that may, or may not be equal. If they are not identical, I want the output to be three new lists, X,Y and Z where X has all the elements that are in A, but not in B, and Y contains all the elements that are B but not in A. Z will then have the elements that are in both A and B. One way of doing this is of course to iterate throug the lists and compare each of the element, but is there a more efficient way? ...
4
4168
by: osmethod | last post by:
Hello, I have read many articles about comparing tables, like - loops, delete queries, appending to temp table with index etc Problem: 2 tables T1 & T2. Data is suppposed to be the same in both tables but i need to check that this is so. (Maybe a user deleted a row in one table only or changed a value in a field!). The tables have no unique index.
0
1692
by: laxmiuk | last post by:
I've original version of a table called PMM (Product Material Master). Thro' a web interface, user can change that table contents. Once changed, i need to raise an ECN (Engineering CHange Note) specifying what changes happened to original PMM table whether rows are deleted, new rows are added or existing rows are modified etc. I've both old and new version of PMM tables. The difference between two PMM tables are captured in a third table...
2
1716
by: windandwaves | last post by:
Hi Guys I want to find out if two tables are identical (e.g. same fields, same indexes, etc....). Not the data, but the table structure itself. Is there a smart way to do that? Cheers
1
2869
by: Reg Rat | last post by:
Hello all, I'm led to believe that the .Net framework offers intelligent string comparison such that é follows e in an alphabetic sort rather than appearing after z, for example. Does this mean that there is a mechanism for comparing strings that may or may not have accents and having them shown as identical (e.g. comparing Herve with Hèrvé would show a match). Ideally, this should be culture neutral as I will not have knowledge of which...
19
2985
by: Will Lastname | last post by:
In one of the applications that I'm working on I have 2 sets of functions that build different datasets. Imagine 4 columns in a datagrid. Inside those 4 columns I have nested datalists. Two of the datalists' datasources point to database A and the other two point to database B. This effect allows the client to perform a side-by-side comparison of the same product so that records can be updated accordingly. It's easy enough to scroll down...
21
2345
by: Kristaps | last post by:
Hi everyone! I have some questions, maybe someone can help me... I write script for table comparing, but it works wery slovly. There is the script, can anyone give some tip how can I make this process faster and if it is possible in VB. The idea is to compare two tables and if there is some distinction, then is written in third table. Some tables contains more than 200 000 rows and each row contain approximatelly 30 parameeters (columns)....
3
2046
by: hasnain | last post by:
Dear All, I want to compare two tables. Both of the tables have same fields but their location in terms of columns can be different. My target is to get those fields only whose values are found different on comparing. Regards Hasnain
5
1862
by: Franck | last post by:
how come unchanged always true even if data changed This code come from my saving button: ============================================ DataSet ds1 = new DataSet(); DataSet ds2 = new DataSet(); DataSet ds3 = new DataSet(); //Static Dataset which contain values when my form load
4
6410
by: gillianbrooks91 | last post by:
Forgive me for asking this question, I've trawled through nearly every available post on this subject that I can find for a few weeks now but nothing quite points me in the right direction. I'm quite new to trying to mess around with VB and ADO within MS Access and have realised the steep learning curve I have, but, I want to try and solve this problem quickly and was wondering if anyone would help me out?? I want to be able to...
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10538
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10285
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7598
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6838
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5494
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2966
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.