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 'AND autores.autor_id=rutas.autor_id AND rutas.tipo_id=tipo_ruta.tipo_id AND ruta' at line 1