问题描述
我被要求使用双重否定在sql中进行查询.问题本身就是要求所有"sigla"和"disciplina",其中semestre_id为21,并且至少具有1个属性"resposta" = 5
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
表
查询
现在尽管发布了所有这些信息,但我的大部分问题仍然是我不太确定这是否是在sql中执行正确的双重否定的方法,因为我得到的是表中所有行的答案,这是错误的.由于我很难在网上搜索示例,因此有人可以澄清一下吗?
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.
这篇关于双重否定SQL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!