gpt4 book ai didi

mysql - 如何获得 subject with and or 条件?

转载 作者:行者123 更新时间:2023-11-29 01:13:42 25 4
gpt4 key购买 nike

select distinct a1.id
from m a1, m a2
on a1.Id = a2.Id
where a1.sub = 'physics' and a2.sub <> 'chem';

我想要一个学过物理但没有学过化学的学生?

给我错误的结果?

有什么输入吗?

最佳答案

通过使用不存在:

select * 
from m a1
where a1.sub = 'physics'
and not exists (select 1 from m where id = a1.id and sub = 'chem')

关于mysql - 如何获得 subject with and or 条件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17726147/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com