Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-07-19 : 08:33:47
|
| Jenny writes "Hi!I have "inherited" an application from a coworker where the sql statements are something like thisSelect akt.avskod, handl.namnfrom akt, handlwhere akt.handlid = handl.handlidI was taught to use joins and would useSelect akt.avskod, handl.namnfrom akt inner join handlon akt.handlid = handl.handlidWhat is the difference? Is there a performance difference? Should I change to my way of writing statements or hang on to the original way?Thanks in advanceJenny" |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-07-19 : 08:38:12
|
| You can use the WHERE syntax, but the ANSI standard for SQL defines the JOIN syntax as the preferred method. In SQL Server, the JOIN clause is processed separately from the WHERE clause, and will most likely optimize better than a WHERE clause-type join. There are lots of instances in which the WHERE syntax leads to goofy results, especially when outer joins are involved. The *= outer join syntax is marked for death, use LEFT JOIN instead.I'd recommend changing them; even though the WHERE syntax will probably still be viable for a long time, it *could* be phased out of the ANSI SQL standard. |
 |
|
|
macka
Posting Yak Master
162 Posts |
Posted - 2002-07-19 : 08:38:24
|
| You are correct to use the inner join syntax. This is the ANSI standard. Check out this link for more info:[url]http://www.swynk.com/friends/boyle/ansijoins.asp[/url]macka. |
 |
|
|
LarsG
Constraint Violating Yak Guru
284 Posts |
Posted - 2002-07-19 : 15:47:20
|
| Robvolk said:You can use the WHERE syntax, but the ANSI standard for SQL defines the JOIN syntax as the preferred method. It does not. There is no such notion as a preferred method in the ANSI standard document. It may be true that one or the another is better optimized in some dbms (as they are equivivalent, this should not really need to be the case). |
 |
|
|
|
|
|