S-SQL and nested joins -- correct version
Eli Naeher
enaeher at gmail.com
Fri Feb 28 01:13:19 UTC 2014
Hello,
My apologies, I sent my previous email by mistake before I'd finished
composing it. Here is the completed email:
Is there an S-SQL expression which will produce nested join expressions
like this one:
select * from table_1
inner join table_2
inner join table_3 on table_2.c = table_3.d
on table_1.a = test_2.b;
(This form is described in section 7.2.1.1 of the Postgres documentation,
which says, "Joins of all types can be chained together or nested: either
or both T1 and T2 can be joined tables.")
I know I can do this:
(:select '* :from 'table-1
:inner-join 'table-2 :on (:= 'table-1.a 'table-2.b)
:inner-join 'table-3 :on (:= 'table-2.c 'table-3.d))
which produces a chained join expression:
(SELECT * FROM table_1
INNER JOIN table_2 ON (table_1.a = table_2.b) INNER JOIN table_3 ON
(table_2.c = table_3.d))
However, these chained join expressions behave differently than nested ones
when mixing different types of joins (inner with outer, etc.), and I need
the behavior of the nested expression. I tried this:
(:select '* :from 'table-1
:inner-join 'table-2
:inner-join 'table-3 :on (:= 'table-2.c 'table-3.d)
:on (:= 'table-1.a 'table-2.b))
But it produces the error "Incorrect join form in select."
Am I missing the correct syntax, or is this unsupported right now?
Thank you,
-Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/postmodern-devel/attachments/20140227/acf36fd7/attachment.html>
More information about the postmodern-devel
mailing list