For example, I'm defining this variable:
@test:= CASE WHEN @age < 21 THEN 'young' WHEN @age > 21 THEN 'old'
Fairly simple and straightforward. This would work when i do it in the SELECT clause, but somehow when i do it in the WHERE clause it gives 0 results, while i can define other variables like @test:= 1
without problems (returning the 10k+ results as expected).
I also tried it in multiple ways but it just doesn't seem to work with the case..when..then situation. Am i missing something or is this just not possible?
EDIT: Not the actual query, but an example of what i mean
SELECT
id, @test
FROM
ratetypes
WHERE
@test:=CASE
WHEN ratetype_id IN (1 , 2, 7, 9) THEN 'numeric'
ELSE 'non numeric'
END