[thelist] new & improved SQL join syntax?

Sarah Adams mr.sanders at geekjock.ca
Fri Jan 19 08:03:12 CST 2007


I regularly read Rudy Limeback's "Ask the Expert" column (it's
fantastic, BTW, I highly recommend it for anyone who writes SQL on a
regular basis). In Wednesday's column he mentioned that the SQL join
syntax I've always used (i.e. a comma-separated list of tables, followed
by one or more WHERE clauses) is outdated. He's mentioned this
previously, but I didn't take it too seriously till I read it again today.

"Please always try to write your joins using JOIN syntax, not the older
style which lists tables using commas."
http://searchoracle.techtarget.com/expert/KnowledgebaseAnswer/0,289625,sid41_gci1239517,00.html

So he's suggesting this syntax is outdated:

      SELECT a.foo, a.field1, b.qux, b.field2
        FROM table1 as a, table2 as b
       WHERE a.field1 = b.field2

and should be replaced with:

      SELECT a.foo, a.field1, b.qux, b.field2
        FROM table1 as a
  INNER JOIN table2 as b
          ON a.field1 = b.field2

Has anyone else heard this, and can they shed any light on it? I guess
I'm just wondering where this change came from, how important it is, do
I need to go back and re-work countless queries to use this syntax, etc?

Also, if anyone has an easy-to-understand tutorial on JOIN clauses
(especially LEFT JOIN and the like), I'd really appreciate it - it's one
of those things that I understand but couldn't for the life of me
explain to someone else :)

-- 
sarah adams
web developer & programmer
portfolio: http://sarah.designshift.com
blog: http://hardedge.ca



More information about the thelist mailing list