473,466 Members | 1,406 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Compare tables

4 New Member
Dear All,
I need to compare two tables with same fields.
Table1(A,B,C)
Table2(A,B,C)
Expand|Select|Wrap|Line Numbers
  1. Select * From Table1,Table2 
  2. Where Table1.A=Table2.A AND Table1.B=Table2.B AND Table1.C=Table2.C
Query don't return a record if a field is empty in both tables and other fields are equal.

Hope someone can help me out. Thanks a bunch! I truely appreciate it.

Regards
Jun 1 '07 #1
6 1395
nico5038
3,080 Recognized Expert Specialist
Did you try:

Expand|Select|Wrap|Line Numbers
  1. Select * From Table1,Table2
  2. Where NZ(Table1.A)=NZ(Table2.A) AND NZ(Table1.B)=NZ(Table2.B) AND NZ(Table1.C)=NZ(Table2.C)
Nic;o)
Jun 2 '07 #2
NeoPa
32,556 Recognized Expert Moderator MVP
I think the following should do it for you. Let us know how you get on.
Expand|Select|Wrap|Line Numbers
  1. SELECT T1.*, T2.*
  2. FROM Table1 AS T1 INNER JOIN Table2 AS T2
  3.   ON T1.A=T2.A AND T1.B=T2.B AND T1.C=T2.C
The SELECT clause may be more than you need but the illustration is there for you to work from at least.
Jun 2 '07 #3
FishVal
2,653 Recognized Expert Specialist
This is basic principe of tristate logic (True, False, Null).
Comparison operations with Null does always return False. This means that Null <> Null in any case.
You may try the following:
Instead Table1.A=Table2.A
one of the following
1) Table1.A=Table2.A OR (Table1.A Is Null AND Table2.A Is Null)
2) IIf(IsNull(Table1.A), DummyValue, Table1.A) = IIf(IsNull(Table2.A), DummyValue, Table2.A)

DummyValue may be any value but the type have to correspond to the field type, e.g. any number for Number field, any string for Text field etc.

Good Luck
Jun 2 '07 #4
nico5038
3,080 Recognized Expert Specialist
This is basic principe of tristate logic (True, False, Null).
Comparison operations with Null does always return False. This means that Null <> Null in any case.
You may try the following:
Instead Table1.A=Table2.A
one of the following
1) Table1.A=Table2.A OR (Table1.A Is Null AND Table2.A Is Null)
2) IIf(IsNull(Table1.A), DummyValue, Table1.A) = IIf(IsNull(Table2.A), DummyValue, Table2.A)

DummyValue may be any value but the type have to correspond to the field type, e.g. any number for Number field, any string for Text field etc.

Good Luck
Thanks for your elaboration about the Null value FishVal, I proposed the NZ() function so each Null will be changed into a "not null" value and can be compared directly.

Nic;o)
Jun 2 '07 #5
PierpaoloScappatura
4 New Member
Did you try:

Expand|Select|Wrap|Line Numbers
  1. Select * From Table1,Table2
  2. Where NZ(Table1.A)=NZ(Table2.A) AND NZ(Table1.B)=NZ(Table2.B) AND NZ(Table1.C)=NZ(Table2.C)
Nic;o)
Thanks this solution work with access but don't work if I work with VB (.Net 2003) and ADO Driver
Jun 4 '07 #6
PierpaoloScappatura
4 New Member
This is basic principe of tristate logic (True, False, Null).
Comparison operations with Null does always return False. This means that Null <> Null in any case.
You may try the following:
Instead Table1.A=Table2.A
one of the following
1) Table1.A=Table2.A OR (Table1.A Is Null AND Table2.A Is Null)
2) IIf(IsNull(Table1.A), DummyValue, Table1.A) = IIf(IsNull(Table2.A), DummyValue, Table2.A)

DummyValue may be any value but the type have to correspond to the field type, e.g. any number for Number field, any string for Text field etc.

Good Luck
Thanks this solution work
Jun 4 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Maur | last post by:
Hi all, I have 2 tables say t_OLD and t_NEW. The new has corrections for audit purposes. They are identical in all respects (i.e. new is a copy of old and then changes are made to t_new) ...
5
by: Megan | last post by:
Hi everybody- I'm helping a friend with a music database. She has an old one and is creating a new one. She wants to compare records and fields in the old database with records and fields in the...
8
by: Vincent | last post by:
has any one seen a program to compare mdbs'. I have ran into a few of them, but none seem to really do that job. Basically what I need to do is, take 2 access mdb's and check the differences...
4
by: dfs9 | last post by:
In the article "Delete Duplicate Records From Access Tables" By Danny Lesandrini writes the following: This final suggestion is the most flexible and accurate. Given any table, it generates a...
9
by: VMI | last post by:
I have two tables and I want to compare these two tables with a query( ie. "select * from A where B.key = A.key") and the result will be stored in a 3rd table (table C). is this possible? If...
1
by: Mark | last post by:
by m.r.davies I have 2 tables on seperate Db's (and servers) I want to use a datareader on the first table to pick the booking ref, and then use that booking ref to query the 2nd DB when i have...
0
by: Shaw | last post by:
Our database is constantly updated (input data) from another DB, and sometimes it crashes our ASP.NET applications. My boss told me to write a DB utility app to check DB and make sure all apps are...
17
by: Mark A | last post by:
DB2 8.2 for Linux, FP 10 (also performs the same on DB2 8.2 for Windoes, FP 11). Using the SAMPLE database, tables EMP and EMLOYEE. In the followng stored procedure, 2 NULL columns (COMM) are...
5
by: Edd E | last post by:
Hi, I have a database to store my analyses (Access 2002, WinXp), the basic structure is: TABLE 1 = Sample Info TABLE 2 = Analysis type 1 TABLE 3 = Analysis type 2 TABLE 4 = Analysis type 3 ...
5
by: chazzy69 | last post by:
Ok heres what im trying to achive i am constantly updating the information in a table but know i what know if the data im replacing it with is new, i.e. whether or not i already had the data in the...
0
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,...
0
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...
0
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,...
1
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.