我有一张条件表
id condition member-id
1 Fall A1452
2 Fall A1453
3 Dementia A1452
4 Dementia A1453
5 Fall A1450
6 Headaches A1453现在我想要的是将条件作为参数来传递,比如"Fall,老年痴呆症“,我想要那些同时具有Fall和痴呆条件的成员I。
select * from conditions where condition IN('Fall,Dementia')这回3张记录,但我需要那些两者都有的吗?
记住“跌倒,痴呆”是动态的,它可能会变成“跌倒,痴呆,头痛”。
发布于 2019-03-14 19:20:55
使用条件聚合
select MemberId from
conditions
where condition IN('Fall','Dementia')
group by MemberId
having count(distinct condition )=2 发布于 2019-03-15 06:14:29
select distinct MemberId
from StackOverflow4
where Condition in ('Fall','Dementia')
group by memberId
having count(MemberId)=2 https://stackoverflow.com/questions/55170303
复制相似问题