Jump to content
Xtreme .Net Talk

Recommended Posts

  • *Experts*
Posted

The exact opposite is true. ANSI standard SQL looks like:

SELECT *
FROM Table1 
INNER JOIN Table2 ON Table1.Col1 = Table2.Col1
LEFT OUTER JOIN Table3 ON Table1.Col1 = Table3.Col1

 

The T-SQL version (Microsoft SQL Server specific):

SELECT *
FROM Table1, Table2, Table3
WHERE Table1.Col1 = Table2.Col1
AND Table1.Col1 = Table3.Col1

 

If you use ANSI standard you're more "standard" but it's a bit harder to read. You can do a little bit more with it, since on OUTER joins you can put more than one expression in the ON portion (...ON Table1.Col1=Table2.Col1 AND Table1.Col2 = 5). If you did the same thing in the WHERE clause (still using ANSI sytax for the join), the OUTER might not return rows if the WHERE clause didn't hit. It's hard to explain, but it's a little above your original question anyway :)

 

-ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
  • *Experts*
Posted

Weird indeed :)

 

I used to use the T-SQL syntax in SQL Server (in version 6, and a bit in version 7) and loved it. Now that I've gotten the hang of the ANSI standard, well... jury's still out. I still miss the convenience of the T-SQL code (looks cleaner to me), but the ANSI version is nice (just harder to line things up and I'm an anal "keep the code clean looking" kinda guy).

 

-Ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...