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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inner Join may be?

Status
Not open for further replies.

JustWondering

Technical User
Jun 28, 2003
57
US
Hi,

How do I do a query that will return common records from 3 tables which have 3 fileds match. I've tried the inner join inside another inner join but it gave me error.

Thanks
 
Have you tried the query builder in enterprise manger
pick one table, right click, select open table,query - add the other tables, drag a link between the common fields, check the fields you want to select etc...
away you go.

This does not always generate the optimum query but for basic stuff its pretty convenient. Anyway to help get you started this query will return all fields in all three tables where fields f1, f2 and f3 are equal

SELECT *
FROM Table1 a INNER JOIN
Table2 b ON a.f1 = b.f1 AND a.f2 = b.f2 AND a.f3 = b.f3 INNER JOIN
Table3 c ON b.f1 = c.f1 AND b.f2 = c.f2 AND b.f3= c.f3
Hope this helps.
 
Thanks SonOfEmidec1100. The query works great and thanks for showing me how to use the query builder in enterprise manager too. I've never tried that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top