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 favorito.id_contenido=contenido.id_contenido AND (contenido.activo<>'N')' at line 8