sql construct condition with if statement mysql
I want to construct such sql condition. I have a table car, it has such
fields id_status, id_category and storage_address. I need to select cars
which are id_status in (2,4) and if id_category = 4 I need to check field
storage_address to be not null or empty. How could I make it? should I use
sql if statement? I need something like:
select * from car where id_status in (2,4) and if(id_category =
4,storage_address is NOT NULL,'1=1')
No comments:
Post a Comment