SQL Query Error (SELECT i.*, its.name as item_status,p.name as publisher, i.price as clientprice, su.name as subject, c.name as category , s.name as subcategory FROM (items i left join subjects su on (i.ref_subject = su.id) left join publishers p on (i.ref_publisher = p.id), item_statuses its, categories c, subcategories s) WHERE its.id=i.ref_item_status AND c.id=i.ref_category AND s.id=i.ref_subcategory AND i.ref_category = '3' AND i.ref_subcategory = '5' and its.id = '1' ORDER BY i.title,i.download_date desc, i.ref_category LIMIT -40, 20) : 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 '-40, 20' at line 9