Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select data from two tables with different column 1

Status
Not open for further replies.

tkleader

Technical User
Nov 5, 2002
4
US
Tab1 has two columns (Last:First) and Tab2 has one column Name). What I want to do is select all data where Tab1.last = Tab2.name and Tab1.first = Tab2.name. Here are some sample data:

Tab1.Last : Tab1.Last
Doe : John
Thomas : Barn

Tab2.Name
Doe
John
Jane
Thomas

Based on the data above, it should only display John Doe in Tab1 because both field matches the field in Tab2.

However, my query doesn't work. Please help.
 
Hi

How about

SELECT * FROM Table1 WHERE Table1.First IN (SELECT Name FROM Table2) AND Table1.Last IN (SELECT Name FROM Table2) Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
 
Ken,

Thank you very much! It worked like a charm. Do you know of any website that teaches advance sql query.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top