[thelist] SQL question
Ashok Hariharan
listman at hazard0us.org
Wed Dec 11 02:21:00 CST 2002
Hello Carl:
Dont worry, its not a silly question.
For a long time I was faced with your dilema; why use the JOIN keyword?
I refused to use it simply because the old way was how I had originally
learnt
my SQL . However, nowadays I have completely switched over
to the JOIN syntax. Most importantly, I find Join syntax very clear
compared to
the earlier syntax, when joining many tables in a complex query.
something like:
from a, b ,c
where a.col1 = b.col2
and a.col2 < 50
and b.col2 = c.col1
and b.col3 < 400
and c.col2 between "01/01/01" and "02/02/02"
can become very hard to understand. With the join syntax there is a clear
seperation
of the table joins and conditions, the above query would look like
from
a inner join b on a.col1 = b.col2
inner join c on b.col2 = c.col1
where
a.col2 < 50 and
b.col3 < 400 and
c.col2 between "01/01/01" and "02/02/02"
this clears the ambiguity with the earlier syntax: should the filter be
applied before or
after the join ?
HTH
ashok
>So my (possibly stupid) question is: why use the JOIN keyword? What's
>the advantage over a simple WHERE clause join? Is it just a matter of
>clearer syntax (for my money, the JOIN syntax isn't clearer)?
More information about the thelist
mailing list