===problem===
i'm using a LEFT JOIN, SQL expression, on 3 tables. i'm getting an unexpected error "JOIN expression not supported" from MS ACCESS 2007 when i try to run it.
===details===
these tables are all connected
- parent: is at the highest level
- child1: child of parent
- child2: child of parent
- grandchild1: child of child1
this is the SQL expression causing the error:
SELECT *
FROM ((grandchild1 AS gc
LEFT JOIN child1 AS c1 ON gc.child1_id=c1.id)
LEFT JOIN parent AS p ON c1.parent_id=p.id)
LEFT JOIN child2 AS c2 ON (p.id=c2.parent_id
AND c2.start<=gc.time AND gc.time<=c2.stop)
strangely, the following expression in which i've only replaced one of the Boolean expressions with TRUE in the "ON" clause does get accepted:
SELECT *
FROM ((grandchild1 AS gc
LEFT JOIN child1 AS c1 ON gc.child1_id=c1.id)
LEFT JOIN parent AS p ON c1.parent_id=p.id)
LEFT JOIN child2 AS c2 ON (TRUE
AND c2.start<=gc.time AND gc.time<=c2.stop)
===questions===
- is there something wrong with the syntax of my expression?
- another things i have noticed is that i can't use an EXISTS clause inside the ON clause, is that normal?
===solution=== (thanks David-W-Fenton)
SELECT *
FROM ((grandchild1 AS gc
INNER JOIN child1 AS c1 ON gc.child1_id=c1.id)
INNER JOIN parent AS p ON c1.parent_id=p.id)
INNER JOIN child2 AS c2 ON (p.id=c2.parent_id)
AND (c2.start<=gc.time) AND (gc.time<=c2.stop)