I cannot seem to find the error in my MySQL query. It states that I have not unique table alias for table usuarios_grupos
However, my table usuarios_grupos only appears once!
My query is the following:
SELECT DISTINCT usuarios.id_usuario
FROM usuarios
WHERE usuarios.id_usuario
NOT IN
(SELECT DISTINCT id_usuario FROM usuarios_grupos, grupos
WHERE usuarios_grupos.id_grupo = grupos.id_grupo)
Any idea why this is happening?
Your table
usuarios_gruposappears once butid_usuariomight be in two tables so you have to be specific and try use join instead and there are no need forDistictlike this: