patternMinor
Joining 3 tables using SQL Query?
Viewed 0 times
tablessqlqueryusingjoining
Problem
I'm having problems joining three tables. It works well when I use the same query for joining two tables (after removing
This is my query
LEFT OUTER JOIN C ON B.No = C.No). However, it doesn't work when I use three tables.This is my query
SELECT A.Name, B.Quantity, C.Quantity
FROM A
LEFT OUTER JOIN B
ON A.ID = B.ID
LEFT OUTER JOIN C
ON B.No = C.No;Solution
MS-Access is rather picky at how it wants the joins to be formed. Add parentheses:
Standard SQL syntax - and most other DBMS - do not need require parentheses in the
SELECT A.Name, B.Quantity, C.Quantity
FROM
( A LEFT OUTER JOIN B ON A.ID = B.ID )
LEFT OUTER JOIN C ON B.No = C.No ;Standard SQL syntax - and most other DBMS - do not need require parentheses in the
FROM clause, although you are allowed to use them for clarity.Code Snippets
SELECT A.Name, B.Quantity, C.Quantity
FROM
( A LEFT OUTER JOIN B ON A.ID = B.ID )
LEFT OUTER JOIN C ON B.No = C.No ;Context
StackExchange Database Administrators Q#28095, answer score: 7
Revisions (0)
No revisions yet.