Double negation sql query

ぃ、小莉子 提交于 2019-12-13 06:21:12

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!