Select 全部为逗号分隔字符串的数据
Select Data which have all comma separated strings
我有一个 table 的条件,例如
id condition member-id
1 Fall A1452
2 Fall A1453
3 Dementia A1452
4 Dementia A1453
5 Fall A1450
6 Headaches A1453
现在我想要的是将条件作为参数传递,例如 "Fall,Dementia"
我想要那些同时具有 Fall 和 Dementia condition
的会员 ID
select * from conditions where condition IN('Fall,Dementia')
这 return 3 条记录,但我需要两者都有的记录?
记住 "Fall,Dementia" 是动态的,它可能会更改为 "Fall,Dementia,Headaches"
使用条件聚合
select MemberId from
conditions
where condition IN('Fall','Dementia')
group by MemberId
having count(distinct condition )=2
select distinct MemberId
from Whosebug4
where Condition in ('Fall','Dementia')
group by memberId
having count(MemberId)=2
我有一个 table 的条件,例如
id condition member-id
1 Fall A1452
2 Fall A1453
3 Dementia A1452
4 Dementia A1453
5 Fall A1450
6 Headaches A1453
现在我想要的是将条件作为参数传递,例如 "Fall,Dementia" 我想要那些同时具有 Fall 和 Dementia condition
的会员 IDselect * from conditions where condition IN('Fall,Dementia')
这 return 3 条记录,但我需要两者都有的记录?
记住 "Fall,Dementia" 是动态的,它可能会更改为 "Fall,Dementia,Headaches"
使用条件聚合
select MemberId from
conditions
where condition IN('Fall','Dementia')
group by MemberId
having count(distinct condition )=2
select distinct MemberId
from Whosebug4
where Condition in ('Fall','Dementia')
group by memberId
having count(MemberId)=2