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 |
pelegk2
Aged Yak Warrior
723 Posts |
Posted - 2013-06-17 : 04:40:35
|
i want to query table, and on the where to do something like:select...Wherecol1 in (case when @param1='' then select id from tbl2 else col1)And name like '%aaaa'how can i do this? |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-06-17 : 04:46:51
|
[code]select...Wherecol1 in (select id from tbl2) or @param1 <> ''[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
pelegk2
Aged Yak Warrior
723 Posts |
Posted - 2013-06-17 : 04:48:17
|
you missed the else point |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-06-17 : 04:53:20
|
i didnt. i replaced it with or. check and see the resultWhere(col1 in (select id from tbl2) or @param1 <> '')And name like '%aaaa' ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
pelegk2
Aged Yak Warrior
723 Posts |
Posted - 2013-06-17 : 05:11:10
|
ok 10X works. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-06-17 : 05:17:56
|
welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|