[thelist] SQL Joins - ANSI 92 syntax

Steve Lewis slewis at macrovista.net
Tue May 21 17:04:43 CDT 2002


Howard Cheng wrote:

> You've pretty much got it already:
>
> SELECT table1.one_name
> FROM table1, table2
> WHERE table1.two_id = table2.two_id
> AND table2.two_name != 'George'

I have been digging into SQL stuff rather heavily lately and wanted to
pull some of that reading out into application.  As I understand it,
this syntax is not ANSI 92 compliant and there is a good reason that the
standard doesn't support this syntax (potential ambiguities in order of
joins when you mix inner and outer joins).  Granted, this query is
simple enough (relatively) that there is no potential ambiguity for the
parser, but I prefer to cultivate good habits.  Am I correct however in
this understanding?

ANSI 92 syntax would make the join explicit in the FROM clause, rather
than in the WHERE clause:

SELECT table1.one_name
FROM table1 INNER JOIN table2
    ON table1.two_id = table2.two_id
WHERE table2.two_name != 'George'

--Steve





More information about the thelist mailing list