I have the following query in a stored procedure:
SELECT *
FROM tempProfile
WHERE 1 = 1
and case when l_primarymailingaddress = 'address1' then find_in_set(add1_stateid,p_stateid) or p_stateid is NULL
when l_primarymailingaddress = 'address2' then find_in_set(add2_stateid,p_stateid) or p_stateid is NULL end;
I am passing a list of IDs in on p_stateid.
The first case finds matches, but the second case doesn't.
So if, for example, I pass in a 7, I do get back all results that have 7 in add1_stateid, the query is not returning results that have 7 in add2_stateid.
Comparing against every example and description I can find this should work.
Is anyone able to see what I am doing wrong here?
Many Thanks