【发布时间】:2014-02-07 05:40:54
【问题描述】:
我正在尝试在 where 子句中进行选择,其中 case 语句的结果是列名。
这是我尝试过的:
declare @lang int -- this is passed to the stored procedure
declare @productname nvarchar(300) -- this is passed to the stored procedure
select productid from products where
case
when @lang = 1 then producten
when @lang = 2 then productit
when @lang = 3 then productde
end product like @productname
所以,对于英语 (@lang = 1) 我想要:
select productid from products where producten like @productname
虽然我遇到了错误,但不确定自己做错了什么。
【问题讨论】: