I am trying to add case statement to where condition in a query. My query looks like below-
select * from table_name
where
if(id==1) then col1 = 0
else col1 is null
As shown in above query I want to add col1 = 0 in where condition if id-==0 else I want col1 is null in where condition. I tried
select * from table_name
where
case id =1 then (col1 = 0)
else col1 is null
end
But the syntax is incorrect. Is there any way to do this?