我有以下查询:
select id from t1
intersect
select id from t2
intersect
select id from t3
id 在某些表中可能是非唯一的,所以我需要使用 distinct。
一般来说,什么更好:
select distinct id from (
select id from t1
intersect
select id from t2
intersect
select id from t3)
或者
select distinct id from t1
intersect
select id from t2 -- here id is unique
intersect
select distinct id from t3