简体   繁体   中英

Double negation sql query

I was asked to do a query in sql using double negation. The question itself is asking for all the "sigla" and "disciplina "where the semestre_id is 21 and has at least 1 attribute "resposta"=5

table http://i.imgur.com/8CDoFHZ.png

query http://i.imgur.com/5aueUKS.png

Now despite posting all this my question is mostly that I am not too sure if this is the way of doing a proper double negation in sql, since I am getting as an answer all the lines of the table which is wrong. Since I am having an hard time searching for examples online could anyone clarify me?

select  disc.disciplina_id, disc.sigla
from    ipdw_disciplina disc
        inner join ipdw_respostas resp
            on disc.disciplina_id = resp.disciplina_id
where   resp.semestre_id = 21
        and resp.resposta = 5
group by disc.disciplina_id, disc.sigla

i try to avoid in / not in whenever possible. It seems easier to follow the intent of the query without them. This looks like a pretty straight forward query that does not need the double negation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM