Reputation: 1552
I have two tables that I'm trying to join. I want to be able to join on ClientID, and only display those records where DateA does not match DateB. This is the structure of my tables
tbl1
CLientID DateA
17 08/01/2016
19 06/27/2016
21 12/1/2015
tbl2
RcrNo ClientID DateB
1 17 08/01/2016
2 19 06/27/2016
3 21 12/22/2015
Desired Result:
ClientID Date
21 12/22/2015
SO as can be seen ClientID 21 is the only client out of the 3 whose DateA does not match DateB. How would I be able to join them like this?
Upvotes: 0
Views: 35
Reputation: 1156
Using JOIN
and WHERE
clause
SELECT *
FROM table1
JOIN table2 ON table1.ClientId = table2.ClientId
WHERE table1.date <> table2.date;
Upvotes: 2
Reputation: 1270031
You can use except
:
select clientid, dateb
from tbl2
except
select clientid, datea
from tbl1;
Upvotes: 1