--测试环境
create table t1(id int)
create table t2(id int)
insert into t1
select 1 union all
select 2 union all
select 3 union all
select 4 union all
select 5 union all
select 6 union all
select 7 insert into t2
select 6 union all
select 9
--sql
select distinct (select distinct t2.id from t1,t2 where t1.id=t2.id)as '有' ,
(select distinct id from t2 where id not in(select id from t1)) as '无'
from t1,t2
--删除环境
truncate table t1truncate table t2
create table t1(id int)
create table t2(id int)
insert into t1
select 1 union all
select 2 union all
select 3 union all
select 4 union all
select 5 union all
select 6 union all
select 7 insert into t2
select 6 union all
select 9
--sql
select distinct (select distinct t2.id from t1,t2 where t1.id=t2.id)as '有' ,
(select distinct id from t2 where id not in(select id from t1)) as '无'
from t1,t2
--删除环境
truncate table t1truncate table t2
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货