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 data DESC' at line 1 in SELECT * FROM post INNER JOIN post_ln ON post.id = post_ln.id_post WHERE id_lang = '1' AND active = 1 AND data <= '2017-12-14' AND id_post = ORDER BY data DESC