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 id_noticia desc limit 3' at line 1 - select noticias.id_noticia from noticias inner join noticias_idioma on noticias.id_noticia=noticias_idioma.id_noticia where tipo='noticias' and enportada=1 and Lenguaje='esp' and noticias_idioma.titulo!='' and noticias.id_noticia!= order by id_noticia desc limit 3