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 DESC LIMIT 3' at line 1 query: SELECT, N.title, N.body, N.img, C.title AS category, SC.title AS subcategory FROM news N INNER JOIN categories C ON = N.id_category LEFT JOIN subcategories SC ON = N.id_subcategory WHERE != 127 AND N.id_category = ORDER BY DESC LIMIT 3