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 - 2004-06-14 : 07:18:36
|
| Mike writes "I would like to be able to dynamically include a where clause based on the value of a selected column. Something like the case function but in the where clauseex:select t1.col1, t2.col2from table1 t1, table2 t2where t1.colID = t2.colID if t1.col1 = 1 and t1.col3 = some value" |
|
|
LarsG
Constraint Violating Yak Guru
284 Posts |
Posted - 2004-06-14 : 07:25:00
|
| [code]select t1.col1, t2.col2from table1 t1, table2 t2where t1.colID = t2.colIDand ((t1.col1 = 1and t1.col3 = 'some value')or coalesce(t1.col1,0) <> 1)[/code] |
 |
|
|
JasonGoff
Posting Yak Master
158 Posts |
Posted - 2004-06-14 : 07:33:46
|
| select t1.col1, t2.col2from table1 t1, table2 t2where t1.colID = t2.colIDand CASE t1.col1 WHEN 1 THEN t1.col3='some value' END |
 |
|
|
|
|
|