Search code examples
c#sqldatabasems-accessoledb

Joining multiple access database tables - Syntax error (missing operator) in query expression


I am trying to join multiple tables from an access database. When I join two it works fine, but I need to join 9. Trying to join 3 like so gives the error:

Syntax error (missing operator) in query expression

Here is my command:

OleDbCommand gpInfoCommand = new OleDbCommand("SELECT * FROM GPInformation " +
                                              "LEFT JOIN GPAvailability ON GPInformation.ID=GPAvailability.GPID " +
                                              "LEFT JOIN GPCustomPayRates ON GPInformation.ID=GPCustomPayRates.GPID", connection);

Solution

  • MS Access requires parentheses around joins when there is more than one. See the examples here: Is it possible to do a 3 table join in MS-Access?