RE: Extremely very complex SQL query with outer's
Posted in 1998
----------
From: ian@tubeway-army.demon.co.uk[SMTP:ian@tubeway-army.demon.co.uk]
Sent: Tuesday, February 03, 1998 8:17 AM
I'm not sure how easy this question is to answer but here goes.
I am perusing some code that has the following statement:
SELECT some_stuff
FROM p1, outer ( menuln p2, outer ( menuln p3,
outer ( menuln p4, outer ( menuln p5 ) ) ) )
WHERE some_conditions
For goodness sake...what's with all the outer's? :-)
JL: They are chained outer joins. I haven't checked the manuals recently, but there used to be
an appendix which discussed Outer Join in much detail, including a diagramming technique to
help understand more complex structures. What you've got there is relatively straight-forward;
it is a linear nesting to 5 levels; much worse would be:
SELECT *
FROM p1, OUTER(menuln p2, menuln p3), OUTER (menuln p4, OUTER(menuln p5))
WHERE lots.of.joining.stuff
You could also look in some of the books by C J Date for explanations of (and diatribes against)
outer joins in general. There's also some explanation in 'Using Informix-SQL' by yours truly.
If the current manuals do not have the appendix on complex outer joins, then (a) we need to tell
doc@informix.com that it has gone missing, and (b) we need to get the material into the FAQ
at www.iiug.org.
Yours,
Jonathan Leffler (jleffler@visa.com) #include <outer.self-joins.are.perverse.h>