I am working with Sybase (sorry I do not konw the version, but can't be too old).
This is what I like to do
SELECT * FROM mytable
where myfield in CASE WHEN @Variable = 1 then ('test1')
WHEN @Variable = 2 then ('test2')
WHEN @Variable = 3 then ('test1','test2')
ELSE ('others','test0')
This is not working, because of the [in] instead of the usual [=] .
Do you know a way I could re-write my query to obtain the result I like (or do I have to test my variable before the select and one select per possible case )
Thank you !
This is what I like to do
SELECT * FROM mytable
where myfield in CASE WHEN @Variable = 1 then ('test1')
WHEN @Variable = 2 then ('test2')
WHEN @Variable = 3 then ('test1','test2')
ELSE ('others','test0')
This is not working, because of the [in] instead of the usual [=] .
Do you know a way I could re-write my query to obtain the result I like (or do I have to test my variable before the select and one select per possible case )
Thank you !