日期:2014-05-18 浏览次数:20593 次
select * from tb t where (select count(distinct filter_id) from tb where product_id=t.product_id and filter_id in(1,2))=2
------解决方案--------------------
declare @T table (product_id int,filter_id int) insert into @T select 1111,1 union all select 1111,2 union all select 2222,1 union all select 2222,3 select product_id from ( select * from @T where filter_id=1 union all select * from @T where filter_id=2 ) a group by product_id having(count(1)=2) /* product_id ----------- 1111 */
------解决方案--------------------