Select query comparing two tables?

  • Thread starter Thread starter VMI
  • Start date Start date
V

VMI

I have two tables, Actual_Employees and Fired_employees (both with the same
fields), and I need to know which custIDs are in both tables AND, of those
with exact CustIDs in both tables, which have the same First_Name and
Last_Name in both tables. So, for example, if there's a record with CustID
"0001", FirstName "Bob", and LastName "Jones" in both tables, this record
should be displayed.

I started with : Select * from Actual_Employees where CustID in (select
CustID from Fired_employees) but I got stuck when checking to see which
records of this resulting group also have the other two conditions (same
First_Name and Last_Name in both tables).

Thanks.
 
This worked for me:

Select * from Actual_Employees inner join Fired_employees on
Actual_Employees.custID = Fired_employees.custID and
Actual_Employees.First_Name = Fired_employees.First_Name and
Actual_Employees.Last_Name = Fired_employees.Last_Name
 
May I ask why you jave two identical tables? Wouldn't it be easier to keep
everything in one table with a field saying whether they are active or
terminated (fired)?

Mich
 
I just made these tables up so I could explain my problem more easily in the
post. Both tables contain entirely different fields.
 
Back
Top