1
In Mysql I have a table called user where all website users are stored:
ID | NOME
1 | bla
2 | ble
3 | bli
4 | blo
And a table called user_management, where are fields related to managing these users:
USUARIO_ID | CREDENCIAL_ID
1 | 1
2 | 1
2 | 2
3 | 1
4 | 1
4 | 2
(the tables are much more complex, I simplified to focus on my doubt)
What I’m not able to do is give a select to users, and NOT show users that have CREDENCIAL_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 users, I even understand that this occurs because users have other credentials beyond 2, but how to do?