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 |
|
JeniQ
Starting Member
29 Posts |
Posted - 2009-08-20 : 12:51:10
|
| A colleague and I were both working on the same query. She wrote her query in a manner completely unlike mine. I was wondering if I could get some advice on the two approaches. Is either better? Both queries return the correct (same) results and take less than one second to run. Option #1select Publication.PublicationID from Publication, Event_Publication where Publication.PublicationID = Event_Publication.PublicationID and EventID = 3427Option #2select p.PublicationIdfrom Publication p join Event_Publication ep on p.PublicationID = ep.PublicationIDwhere ep.EventID = 3427 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-08-20 : 12:55:56
|
#2 is better.The old way to join tables using comma like done in #1 is "deprecated" and will not work in the future.Also #2 is much better readable. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
JeniQ
Starting Member
29 Posts |
Posted - 2009-08-20 : 12:59:16
|
| I win, I win!!! :) |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-08-20 : 13:03:59
|
Congrats! No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-08-21 : 01:45:12
|
| Also #2 is ANSI styleIf you omit where clause in #1, it is cross joinMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|