none
Using 2 Left Join Queries in SQL for MS Access Database not working RRS feed

  • Question

  • I'm trying to use 2 SQL Left Join Queries in a program that queries an MS Access database, but it's not working.  According to everything I've looked up, the language should look like this:

    SELECT tb1.f1, tb2.f2, tb3.f3 FROM tb1 LEFT JOIN tb2 ON tb2.ID = tb1.fX LEFT JOIN tb3 ON tb3.ID = tb1.fY;

    Unfortunately, I receive an error each time.  The error is:

    Syntax error (missing operator) in query expression 'tb2.ID = tb1.fX LEFT JOIN tb3 ON tb3.ID = tb1.fY'

    Does Access require an operator of some sort between JOIN statements?  I don't think that's generally required by SQL.

    Saturday, June 21, 2014 6:20 PM

Answers

  • You need parentheses:

    SELECT tb1.f1, tb2.f2, tb3.f3 FROM (tb1 LEFT JOIN tb2 ON tb1.fX = tb2.ID) LEFT JOIN tb3 ON tb1.fY = tb3.ID;


    Regards, Hans Vogelaar (http://www.eileenslounge.com)


    Saturday, June 21, 2014 6:45 PM

All replies

  • You need parentheses:

    SELECT tb1.f1, tb2.f2, tb3.f3 FROM (tb1 LEFT JOIN tb2 ON tb1.fX = tb2.ID) LEFT JOIN tb3 ON tb1.fY = tb3.ID;


    Regards, Hans Vogelaar (http://www.eileenslounge.com)


    Saturday, June 21, 2014 6:45 PM
  • That worked!  Thanks.
    Saturday, June 21, 2014 7:13 PM