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 product_special DESC, name ) AS f' at line 8 SQL=SELECT COUNT(id) AS nb FROM ( SELECT product_special AS ordre_princ, p.product_id AS id, p.product_name AS name, c.category_id AS cat_id FROM jos_vm_product AS p LEFT JOIN jos_vm_product_category_xref AS c ON c.product_id=p.product_id AND product_list='1' LEFT JOIN jos_vm_product_mf_xref AS m ON m.product_id=p.product_id WHERE product_publish='Y' AND c.category_id='510' AND p.product_id<>4373 AND manufacturer_id= ORDER BY product_special DESC, name ) AS f