0

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);
mbdavis
  • 3,861
  • 2
  • 22
  • 42

2 Answers2

1

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?

Community
  • 1
  • 1
Erik
  • 5,355
  • 25
  • 39
1

MS Access has an arcane syntax for multiple joins that requires parentheses:

SELECT *
FROM (GPInformation LEFT JOIN
      GPAvailability
      ON GPInformation.ID = GPAvailability.GPID
     ) LEFT JOIN
     GPCustomPayRates
     ON GPInformation.ID = GPCustomPayRates.GPID;
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786