问题
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
query
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?
回答1:
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.
来源:https://stackoverflow.com/questions/15681935/double-negation-sql-query