我有一张如下表:
ID Languages Experience
1 c++ 5
1 Java 2
1 Python 7
2 C# 1
2 c++ 4
3 PHP 8
等等。
我希望查询获取特定ID取决于多个非特定条件,例如:
选择包含语言php和Experience> 3以及语言c ++和Experience< 9
的ID答案 0 :(得分:1)
select id
from your_table
group by id
having sum(case when languages = 'php' and experience > 3 then 1 end) > 0
and sum(case when languages = 'c++' and experience < 9 then 1 end) > 0
答案 1 :(得分:0)
这是您使用or
寻找的内容:
select id
from yourtable
where (languages = 'PHP' and experience > 3)
or (languages = 'c++' and experience < 9)