M Mayer
M Mayer

Reputation: 17

Join two tables and compare two columns to see if they are equal

I have two tables in my access DB, I can join the tables based on their primary key, Grant Number, however both tables contain an expiry date column and I want to see if the expiry dates match.

First Table: "Everything2013" 
    Columns: Claim Name, Grant Number, Expiry Date

Second Table: "Yukon Claims Govt" 
    Columns: Claim Name, Claim Owner, Grant Number, StakingDate, ExpiryDate

I want to join the tables based on the Grant Number, which is the primary key, I then want to see if the expiry dates are the same for each grant number from both tables. Basically, I'm checking the expiry dates from one table to see if they match the expiry date for the same grant number in another table.

Upvotes: 0

Views: 10267

Answers (4)

HLGEM
HLGEM

Reputation: 96552

select E.Claim_Name, E.Grant_Number, Y.StakingDate \
from Everything2013 e
inner join Yukon_Claims_Govt  y
on E.[Grant_Number]=Y.[Grant_number]
where E.Expiry_Date=Y.ClaimExpiryDate;

Upvotes: 1

Chamal
Chamal

Reputation: 1449

I assume you want to get the result set which have same grant number and expiry date from two tables.

select Grant_Number,Claim_Name, StakingDate 
from Everything2013
inner join Yukon_Claims_Govt 
on Everything2013.Grant_Number=Yukon_Claims_Govt.Grant_Number
AND Everything2013.Expiry_Date=Yukon_Claims_Govt.ClaimExpiryDate;

Upvotes: 1

Culyx
Culyx

Reputation: 539

Sounds like you want something like:

select Claim_Name, Grant_Number, StakingDate from Everything2013
inner join Yukon_Claims_Govt 
on Everything2013.Expiry_Date=Yukon_Claims_Govt.ClaimExpiryDate;

Upvotes: 0

user240141
user240141

Reputation:

Then why not You put join on expiry dates and extract the other fields.

Upvotes: 0

Related Questions