0
Good afternoon, I would like a help to return names that do not contain the workshop'2' in the registered case. The way I rode, it brings me different from (''), I need that besides different, bring me those who do not have such registered workshop.
Example shows me all with the workshop 1 registered, but who is in 1 does not necessarily have the 2 registered in your user.
SELECT /*usu.rowid,*/
db.cd_usuario,
db.nm_usuario ,
usu.cd_oficina
FROM Usuarios_Oficina_Funcao usu,
usuarios db
WHERE usu.cd_oficina NOT IN ('2','3','4','5','6','7','8')
AND usu.cd_usuario NOT IN ('USUARIO')
AND usu.cd_usuario (+) = db.cd_usuario
ORDER BY cd_usuario
** In the image, the user ADRIANA.SANTOS has the workshop 1 and 2 registered, but the user ADRIELY.SANTOS owns only the workshop 1. I need you to bring me only that does not have the workshop 2 registered, as I exemplified, brought me only the values different from those that are in (). Thank you
"it brings me different from ('')" where is this in the query? it was not clear. "not containing the workshop'2'" this is in the query, it is a bit confused, put in the question data examples of the 2 tables and the result, looking at the query o
NOT IN
already filters that– Ricardo Pontual
I added more information to the question.
– Italo Nhã
cd_oficina is not number? if it is not necessary to quote values, the result seems to be... if it is even text, if it is not exactly
'2'
may not filter, if I had for example some space– Ricardo Pontual
Tried a NOT EXISTS ?
– Motta
In relation to the quotes is not influencing, because it is filtering right. NOT EXISTS did not bring me back, but would be this way? SELECT db.cd_usuario, db.nm_usuario , Usu.cd_oficina FROM Usuarios_oficina_funcao Usu, dbasgu.usuarios db WHERE NOT EXISTS (SELECT 1 FROM Usuarios_oficina_funcao o WHERE o.cd_oficina IN ('2') (OU = 2 also brought no return) AND Usu.cd_usuario (+) = db.cd_usuario ORDER BY cd_usuario
– Italo Nhã