Any reason this can't work?
$sql = "SELECT u.PHONE , u.STATE , if (uo.CHANNEL='wap','wap','web') as TYPE FROM user LEFT JOIN user_oferts uo ON u.PHONE=uo.PHE_USER WHERE (u.STATE='active') ";
MySQL does not like to compare null with string , so you can either embed if uo.CHANNEL IS NULL in another test expression, or rather change your table so that it cannot be null and give it a default value of "wap".
source share