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 |
rajani
Constraint Violating Yak Guru
367 Posts |
Posted - 2005-12-15 : 18:04:28
|
Hi friendsam trying understand the sql concept here.i've 2 tables (master and patient).master is parent and patient is one of child tables to master.whats the difference between two following sql statements, are they same ? which is one most optimised.look at conditions in bold (the both return results i want but curious to know the difference).Thanks1) select master.someflds,patient.somefldsFROM dbo.master INNER JOIN dbo.patient ON dbo.master.MASTERID = dbo.patient.FK_MASTER_MASTERID AND dbo.u_master.TYPE = 'p'2)select master.someflds,patient.somefldsFROM dbo.master INNER JOIN dbo.patient ON dbo.master.MASTERID = dbo.patient.FK_MASTER_MASTERID where dbo.u_master.TYPE = 'p'Cheers |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-12-15 : 18:16:05
|
The 2nd one is the preferred format. They'll return the same result set though. Join conditions should be in the ON portion and filtering should be in the WHERE clause.Tara Kizeraka tduggan |
|
|
nathans
Aged Yak Warrior
938 Posts |
|
rajani
Constraint Violating Yak Guru
367 Posts |
Posted - 2005-12-18 : 14:57:29
|
Thank you Tara and Nathan for your posts.Nathan,thats a nice article .ThanksCheers |
|
|
|
|
|