You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'AND CASE WHEN properties_types.types_fr_typ IS NOT NULL THEN properties_types.ty' at line 46