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

How do multiple LEFT JOINS in one query 1

Status
Not open for further replies.

gazolba

Programmer
Dec 4, 2001
167
US
First can I, and if so how?

I have a table full of ID's which are defined in multiple other tables. I need to resolve everything in one query for a report. Any of the ID's may be Null. e.g.

Main Table:
Client ID - defined in Client table
User ID - defined in User table
Hardware ID - defined in Hardware table
Software ID - defined in Software table

I tried
SELECT ......
FROM tblMain
LEFT JOIN tblClient ON tblMain.ClientID = tblClient.ID,
LEFT JOIN tblUser ON tblMain.UserID = tblUser.ID,
LEFT JOIN tblHW ON tblMain.HWID = tblHW.ID,
LEFT JOIN tblSW ON tblMain.SWID = tblSW.ID

but I get a syntax error.
 
Try:
[tt]
SELECT ......
FROM (((tblMain
LEFT JOIN tblClient ON tblMain.ClientID = tblClient.ID)
LEFT JOIN tblUser ON tblMain.UserID = tblUser.ID)
LEFT JOIN tblHW ON tblMain.HWID = tblHW.ID)
LEFT JOIN tblSW ON tblMain.SWID = tblSW.ID;
[/tt]
 
Amazing what a few parentheses will do. Thanks!
I looked in about 6 books on SQL and none had an example of more than one LEFT JOIN.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top