russell russell - 4 months ago 22
SQL Question

merge 3 tables in sql

I need to merge data from 3 tables across 2 databases in ASP.Net using Access 2007.

TableA resides in one database, tableB and tableC in another, all are on the same server.

My 'Select' statement runs as follows:

Select * from tableA
inner join myfilepathname.tableB on tableA.column1 = tableB.column2
inner join myfilepathname.tableC on tableB.column2 = tableC.column3

tableA doesn't have a data field related to tableC which is why I'm using the joint to tableB to bring the 3 sets of data together.

I keep getting the error message:

'Syntax error (missing operator) in query expression 'tableA.column1 = tableB.column2 INNER JOIN myfilepathname.tableC on tableB.column2 = tableC.column3'

Can anyone help with where I'm going wrong?

Answer Source

Try adding brackets to your query. In Access multiple joins look like below:

SELECT ...
FROM ((origintable
JOIN jointable1 ON ...)
JOIN jointable2 ON ...)