如表1中有3万个电话号码,表2中有5万个号码,如何把这两个表中不同的号码找出来

来源:百度知道 编辑:UC知道 时间:2024/05/24 11:03:26
朋友,谢谢你的回答,还有详细一点吗?

select distinct number from (select distinct 号码 as number from table1 union all
select distinct 号码 as number from table2 )

--t1对t2不匹配
select t1.service_id from t1,t2
where t1.service_id=t2.service_id(+)
and t2.service_id is null;

--t2对t1不匹配
select t2.service_id from t1,t2
where t2.service_id=t1.service_id(+)
and t1.service_id is null;

select * from (
select num from t1
union
select num from t2) t1 where num not in (select t1.num from t1,t2 where t1.num=t2.num)