日期:2014-05-17 浏览次数:20525 次
select
activeName
from (
select 'a1' as TabName,activeName from a1
union all
select 'a2' as TabName,activeName from a2
union all
select 'a3' as TabName,activeName from a3
) as a
group by activeName
having count(distinct TabName)>1
--如果 activeName在各表中是唯一的可以直接 COUNT(1)>=2
SELECT activeName,COUNT(1) FROM
(
SELECT activeName FROM A1
UNION ALL SELECT activeName FROM A2
UNION ALL SELECT activeName FROM A3
)TB
GROUP BY activeName HAVING COUNT(1)>=2