日期:2014-05-16  浏览次数:20879 次

请教高手,我想找出多个数据表中的相同数据,SQL语句怎么写?
就是多个数据表里,有相同的数据,要全部查找出来,SQL语句怎么写?先谢了!


------解决方案--------------------
where A.col1=B.col1 and A.col2=B.col2 and A.col3=B.col3 and ...
------解决方案--------------------
select col1,col2,col3
from (
select * from tab1
union all
select * from tab2
union all
select * from tab3
) t
group by col1,col2,col3
having count(*)>1