Error Query en SELECT articulos.* , temas_por_articulo.tema FROM `articulos` LEFT OUTER JOIN temas_por_articulo ON articulos.id = temas_por_articulo.articulo having articulos.sys_delete is null and temas_por_articulo.tema= order by id desc 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 desc' at line 1