create table test1(a1 int,a2 int)
insert into test1 select 1,2create table test2(a1 int,a2 int,a3 char(4),a4 char(2))
insert into test2 select 1,3,1,1test2表 ,希望得到效果:
a1 a2 a3 a4
1 3 1 1
1 2 null null
insert into test1 select 1,2create table test2(a1 int,a2 int,a3 char(4),a4 char(2))
insert into test2 select 1,3,1,1test2表 ,希望得到效果:
a1 a2 a3 a4
1 3 1 1
1 2 null null
union all
select *,null,null from test1
select *,null,null from test1select * from test2
select *,null,null from test1
null也要写上去?
select * from test1select * from test2
insert into test1 select 1,2create table test2(a1 int,a2 int,a3 char(4),a4 char(2))
insert into test2 select 1,3,1,1select m.* from test2 m
union all
select n.* , null , null from test1 n drop table test1 , test2/*
a1 a2 a3 a4
----------- ----------- ---- ----
1 3 1 1
1 2 NULL NULL(所影响的行数为 2 行)*/