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