日期:2014-05-17 浏览次数:20574 次
SELECT *
FROM t1
WHERE id IN ( SELECT *
FROM ( SELECT id
FROM [t2]
WHERE [type] = 1
UNION
SELECT id
FROM [t2]
WHERE [type] = 2
) a )
select * from t1 As a
Where Exists(select 1 from t2 As x
Where x.id=a.id
And x.type=1
)
And Exists(select 1 from t2 As x
Where x.id=a.id
And x.type=2
)
SELECT id FROM [t2] WHERE [type] = 1
INTERSECT
SELECT id FROM [t2] WHERE [type] = 2