sql construct condition with if statement mysql -
i want construct such sql condition. have table car, has such fields id_status , id_category , storage_address . need select cars id_status in (2,4) , if id_category = 4 need check field storage_address not null or empty. how make it? should use sql if statement? need like: select * car id_status in (2,4) , if(id_category = 4,storage_address not null,'1=1') try this: select * car id_status in (2,4) , if( id_category = 4, storage_address not null, 1 ) simply put, not need string '1=1' , plain 1 truthy value. or can select * car id_status in (2, 4) , ( id_category != 4 or storage_address not null )