Unmatched Query question (1 Viewer)

tlr123

New member
Local time
Today, 05:47
Joined
Jul 3, 2019
Messages
1
I am trying to create a query where multiple fields match but one is different.

Example:

Table 1:

Name Date Age
John 1/1/18 30
Jane 6/1/19 25
Bob 5/4/17 40

Table 2:

Name Date Age
John 1/1/18 62
Jane 6/1/19 42
Bob 5/4/17 15

I am trying to say in my query: match where name and date are the same but show me where the age differs.
 

Ranman256

Well-known member
Local time
Today, 06:47
Joined
Apr 9, 2015
Messages
4,337
join tables on Name, Date
bring down tbl1.date

under criteria :

tbl1.date
<> tbl2.date
 

isladogs

MVP / VIP
Local time
Today, 11:47
Joined
Jan 14, 2017
Messages
18,219
The previous answer won't give what you asked for.
As stated, join tbl1 & tbl2 using Name and Date.
Add Age from tbl1 and set its criteria as <>tbl2.Age

Also, as Age changes, it should never be saved in a table.
Instead store date of birth and calculate Age using a query when needed.

Do your tables have a primary key field?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 18:47
Joined
May 7, 2009
Messages
19,242
something like:
Code:
Select Table1.Name, Table1.Date, Table1.Age As Table1_Age, Table2.Age As Table2_Age
 From Table1 Left Join Table2 On Table1.Name = Table2.Name And Table1.Date = Table2.Date;
then you can see both ages on both table.
 

Users who are viewing this thread

Top Bottom