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 |
|
johnstern
Yak Posting Veteran
67 Posts |
Posted - 2007-06-13 : 17:14:24
|
| I am trying to figure out the right systax to put a where clausing in a join, rather than having to join all the records first before, filtering as a whole. I think I read that using IN is not recommended for a stored procedure, is this correct ?, I may have miss understood e.g.select * from where state in (wi,mi,ma) |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-06-13 : 17:21:59
|
| You misunderstood. Using IN is fine in a stored procedure. Sometimes, you can use a join instead if the IN is using a query.Tara Kizerhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
sshelper
Posting Yak Master
216 Posts |
Posted - 2007-06-13 : 18:04:14
|
| >> I am trying to figure out the right systax to put a where clausing in a join, rather than having to join all the records first before, filtering as a whole. <<To put the condition in a JOIN, simply include it in the ON clause of the JOIN:SELECT <YourColumns>FROM TableA INNER JOIN TableBON TableA.ID = TableB.ID AND TableA.Column1 = 1 AND TableB.Column2 = 'ABC'SQL Server Helperhttp://www.sql-server-helper.com |
 |
|
|
|
|
|