In MySQL I have a table named user where all users of the site are stored:
ID | NOME
1 | bla
2 | ble
3 | bli
4 | blo
And a table called user_administration , where there are fields related to the management of these users:
USUARIO_ID | CREDENCIAL_ID
1 | 1
2 | 1
2 | 2
3 | 1
4 | 1
4 | 2
(the tables are much more complex, simplified to focus on my doubt)
What I am not able to do is to give a select on users, and DO NOT show users who have the CREDENTIAL_ID = 2, my code so far:
SELECT usuario.id AS usuarioId FROM usuario
LEFT JOIN usuario_gerenciamento ON usuario.id = usuario_gerenciamento.usuario_id
WHERE usuario_gerenciamento.credencial_id <> 2
But it shows all the users, I even understand that this happens because the users have other credentials besides the 2, but how to do?