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

Multiple Inner Joins, 2 from 1 table 1

Status
Not open for further replies.

BB101

Programmer
May 23, 2001
337
GB
I have a table with a few joins to other tables... I want to run a select to get out all the data from its linked tables, it has these headings

ID, Category, RoundResID, ProdResID.

RoundResID and ProdResID both point to a Resources table, which has a field called "name" (what I want), Category points to a BuildCats Table, I want a the "name" col again... I can do the Category Join:

SELECT BuildCats.Name AS Category, Buildings.Name AS Name,
FROM Buildings
INNER JOIN BuildCats ON Buildings.Category = BuildCats.ID

How can I reference 2 feilds to get their Names from Resources
 
Assuming your Resource Table name is Resources and the PK of it is ResID,another column is "Name"; the Query is:


SELECT BuildCats.Name AS Category, Buildings.Name AS Name,RR.Name as [Round Resource Name],PR.Name as [Prod Resource Name]
FROM Buildings
INNER JOIN BuildCats ON Buildings.Category = BuildCats.ID
Inner Join Resources as RR on Buildings.RoundResID=RR.ResID
inner join Resources as PR on Buildings.ProdResID=PR.ResID


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top