Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Join on a third table

Author  Topic 

Bobba Buoy
Starting Member

36 Posts

Posted - 2003-06-17 : 07:52:09
I currently have a join on 2 tables. An abbreviation of the code is as follow:

sql = "SELECT pd.RaceID, ir.EventPl, ir.RacePl FROM PartData pd INNER JOIN IndResults ir ON pd.PartID = ir.PartID WHERE pd.RaceID = " & lRaceID & " ORDER By EventPl"

Here's the problem: I need to change the WHERE clause to a field value from another table. How do I incorporate a join with a third table?

Thanks!


dsdeming

479 Posts

Posted - 2003-06-17 : 08:50:55
The simple answer is you join to a third table the same way you joined to the second. As long as the third table contains some common column(s) with one of the other tables, you can join to it:

SELECT pd.RaceID,
ir.EventPl,
ir.RacePl
FROM PartData pd
INNER JOIN IndResults ir ON pd.PartID = ir.PartID
JOIN ThirdTable t ON pd.whatever = t.whatever
WHERE pd.RaceID = " & lRaceID & "
AND t.filter = @value
ORDER By EventPl

Dennis
Go to Top of Page
   

- Advertisement -