Query with NOT IN in mysql

0

I have 2 tables (official and official_situation). I need to bring the officials in their proper situations.

The big x of the issue is not to bring some employees who are in some situations (exception).

I have this query, but it still displays the codes I do not want to appear.

Where am I going wrong?

SELECT DISTINCT 
    a.funcionario_situacao, 
    b.funcionariosituacao_title AS title 
FROM (".DB_FUNCIONARIO." a 
JOIN ".DB_FUNCIONARIOSITUACAO." b ON a.funcionario_situacao = b.funcionariosituacao_id)
WHERE a.funcionario_situacao NOT IN (:excecao)
ORDER BY b.funcionariosituacao_title ASC", "excecao=1,2,3,4,5,14,15"
    
asked by anonymous 11.08.2017 / 02:17

1 answer

0

I did not see any major problems in your query, it just did not bring the employee's name or id, and I removed a parent from the / join that I believe should not be there. Check the result:

SELECT DISTINCT 
    a.funcionario_nome,
    a.funcionario_situacao, 
    b.funcionariosituacao_title AS title 
FROM DB_FUNCIONARIO a 
INNER JOIN DB_FUNCIONARIOSITUACAO b ON a.funcionario_situacao = b.funcionariosituacao_id
WHERE a.funcionario_situacao NOT IN (1,2,3,4,5,14,15)
ORDER BY b.funcionariosituacao_title ASC
    
11.08.2017 / 04:50