You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'and segmento like '%FAMILY%' ) order by PRIORITY desc, data desc limit 0,100' at line 1select distinct opportunita.*,'opportunita' as tabella from opportunita where ( and segmento like '%FAMILY%' ) order by PRIORITY desc, data desc limit 0,100