Database error SELECT *, rating as rating_number, IF(CURDATE() < date(priority_date_limit),priority,0) as priority, IF( (SELECT count(*) FROM `tbl__pro_accounts` WHERE resident_id = `vw__area_list_pro`.`tbl_obj_id` AND resident_type = 'area' AND is_payed = true AND now() BETWEEN date_start AND date_end) OR NOW() < pro_date_limit, true, false ) as isPro FROM vw__area_list_pro WHERE tbl_obj_id IN () AND active = 1 AND registration_confirmed = 1 ORDER BY priority DESC, isPro DESC, rating_number DESC, title LIMIT 0,25