tags:

views:

58

answers:

1

I have a sql statement with multiple left joins that I cannot get to work in Access 2007, the message stating,

JOIN expression not supported

SELECT
  Foo.A,
  Bar.B,
  Baz.C,
  Bat.D
FROM
  Foo
LEFT JOIN
  Bar ON Foo.BarId = Bar.BarId
LEFT JOIN
  Baz ON Foo.BazId = Baz.BazId
LEFT JOIN
  Bat ON Foo.BatId = Bat.BatId

WHERE 
  Foo.CriteriaColumn = 1

What is the correct format for Access 2007?

+3  A: 

It's been a while since I did joins in Access, but enclosing each join expression separately in parentheses should do the trick:

SELECT
  Foo.A,
  Bar.B,
  Baz.C,
  Bat.D
FROM
  ((Foo
LEFT JOIN
  Bar ON Foo.BarId = Bar.BarId)
LEFT JOIN
  Baz ON Foo.BazId = Baz.BazId)
LEFT JOIN
  Bat ON Foo.BatId = Bat.BatId
WHERE 
  Foo.CriteriaColumn = 1
Christian Hayter
+1, I was just about to post the same thing. http://office.microsoft.com/en-us/access/HA012314891033.aspx?pid=CH100728991033
Chris
Thanks for the link Chris! I'll just remove the OUTER bit since that seems to be T-SQL only after all. :-)
Christian Hayter
Perfect, thank you
blu