56,677
社区成员
发帖
与我相关
我的任务
分享
select productId
from 如表
where (attr='颜色' and content='红色')
or (attr='长度' and content='10厘米')
or (attr='宽度' and content='20厘米')
group by productId
having count(*)=3
select distcint productId
from 如表 a
where exists (select 1 from 如表 where productId=a.productId and attr='颜色' and content='红色')
and exists (select 1 from 如表 where productId=a.productId and attr='长度' and content='10厘米')
and exists (select 1 from 如表 where productId=a.productId and attr='宽度' and content='20厘米')
select productId
from 如表 a , 如表 b
where a.productId=b.productId
and a.attr='颜色' and a.content='红色'
and b.attr='长度' and b.content='10厘米'