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_ln.id_post WHERE id_lang = '1' AND active = 1 AND data <= '2019-03-20' AND id_post = ORDER BY data DESC