SQL Selecting from 3 tables returns syntax error
I have 3 tables on which i need to select data from using ms-access DB
I tried this SQL:
SELECT a.column1, a.column2, a.column3, a.columnID, b.column1
From TableA a INNER JOIN TableB b
ON a.columnID = b.columnID INNER JOIN TableC c
ON c.columnID = a.columnRelativeID
WHERE a.columnID=16
Although when I try to execute the query I receive Syntax error.
In addition, 开发者_运维知识库when i remove the second join, with the third table, the query works fine so this is the place where the error stays.
This example of joining 3 tables didn't help me understand where my problem is.
Is it OK if I just select from two tables and complete the third-table data from a LINQ in C#? I have the Third-table data in a data source in my code
Thanks in advance,
Oz.
You can absolutely select from three (or more) tables in MS Access. However, you have to use Access' craptastic parenthesis system which pairs tables together in the From clause.
Select A.Column1, A.Column2, A.Column3, A.ColumnID, B.Column1
From (Table1 AS A
Inner Join Table2 AS B
On A.ColumnID = B.ColumnId)
Inner Join Table3 AS C
ON A.ColumnRelativeId = C.ColumnId
Where A.ColumnId = 16
SELECT a.column1, a.column2, a.column3, a.columnID, b.column1
From TableA a , TableB b, TableC
WHERE a.columnID = b.columnID
AND c.columnID = a.columnRelativeID
AND a.columnID=16
精彩评论