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 'ORDER BY oferta, idproducto DESC LIMIT 0, 150' at line 1SELECT * FROM t_productos WHERE borrado=0 AND (codproductopadre IS NULL OR codproductopadre=0) AND 1=1 AND ORDER BY oferta, idproducto DESC