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 noticias_dc.categoria != 20 GROUP BY noticias_dc.id ORDER BY noticias_dc.' at line 1