You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ORDER BY c.dth_inc DESC LIMIT 0,5' at line 9 SELECT SQL_CALC_FOUND_ROWS c.id_conteudos, DATE_FORMAT(c.dth_inc, '%d/%m/%Y'), c.den_titulo FROM conteudos_categorias cc JOIN conteudos c ON (c.id_conteudos_categorias = cc.id_conteudos_categorias) WHERE c.id_conteudos <> 1 AND c.id_conteudos_categorias = ORDER BY c.dth_inc DESC LIMIT 0,5