Re: CROSS JOIN
- From: "--CELKO--" <jcelko212@xxxxxxxxxxxxx>
- Date: 16 Jan 2006 15:58:17 -0800
>> There is nothing to say that it will be depreciated in a future ANSI specification. <<
It is possible, but we talked about that years ago and the concensus
was that depreciating the original FROM .. WHERE syntax would never
happen. Too much old code depends on it and WHERE is different from
ON. You need both and woudl have to invent a totally different
syntax.
The problem is that the WHERE clause is done after the FROM clause.
This makes a honking big difference in OUTER JOINs:
SELECT a, b, c
FROM Foo LEFT OUTER Bar ON a = 42 AND b = 32;
is not the same as:
SELECT a, b, c
FROM Foo LEFT OUTER JOIN Bar ON a = 42
WHERE b = 32;
>> It also makes sense when you start using outer joins, the mixed syntax is horrible imho and leads to more work when diagnosing performance problems / supporting the SQL <<
You have no choice about the OUTER JOIN, OUTER UNION, etc. syntax, of
course. And I agree that INNER JOIN with OUTER JOIN is usually a good
idea. It lets you put parens in the right places as you look at the
code.
The only down side is that you start thinking in binary operators
applied in a sequential order, just like you did with procedural code
instead of more abstract concepts.
But I prefer the old FROM.. WHERE syntax instead of a chain of INNER
JOINs. The extra words crowd the page and make the code hard to read,
as well as hiding relationships. Consider this simple search
condition:
SELECT a, b, c
FROM Foo, Bar, Gulk
WHERE Foo.a BETWEEN Bar.b AND Gulk.c;
You can see the "between-ness" relationship. Now look at this and see
that higher level declarative concept of "between-ness" is lost in the
forest.
SELECT a, b, c
FROM (Foo
INNER JOIN
Bar
ON Foo.a >= Bar.b)
INNER JOIN
Gulk
ON Foo.a <= Gulk.c;
Foo is at the top, but it is used at the bottom of the code block.
This is not good when you are debugging code. The code you want to
look at should be physically close together and not several lines a
part
Add a few parens in the wrong places, build a derived table with a bad
column name and it can be a mess to debug.
.
- Follow-Ups:
- Re: CROSS JOIN
- From: Joachim Pense
- Re: CROSS JOIN
- From: Tony Rogerson
- Re: CROSS JOIN
- References:
- CROSS JOIN
- From: David Segall
- Re: CROSS JOIN
- From: Tony Rogerson
- CROSS JOIN
- Prev by Date: Re: CROSS JOIN
- Next by Date: Is MySQL File Format Identical to SQL File Format?
- Previous by thread: Re: CROSS JOIN
- Next by thread: Re: CROSS JOIN
- Index(es):
Relevant Pages
|