var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: simple case in where clause
I'm trying to get a case statement to work with 'IN', in the where clause but it doesn't like the syntax.
WHERE column_1 IN case when@variable = 1 then (2, 3, 4, 5) else (@variable)
Is this workable?
WHERE (@variable = 1 and column_1 in (2, 3, 4, 5))
or column_1 = @variable
u can't use the case statement in where clause
use blindman solution r try this to
select * from urtable where column_1 in (1,2,7)
select * from urtable where column_1 =@variable
True. But you can use the CASE expression
Originally Posted by
In SQL, it's a Case Expression, *not* a Case Statement
ur codings are working excelent.
I've confused myself now.
Won't your solution cause table/index scans blindman?
Propose a better one. You could do a variation of bklr's script using a UNION statement instead.
If performance is an issue here then I'd go with blkr's construct. If not, then I'd settle for a table scan
BKLR's would result in alternate execution plans, as opposed to a UNION statement which would be a single execution plan.
I think UNION is the preferred method, but I also confess to not really caring much between the two.