问题
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?
回答1:
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
来源:https://stackoverflow.com/questions/1527752/how-should-this-sql-with-left-joins-be-written-in-access-2007