select id,AreaName,AreeaKey,Px into bb from
(select id,province as AreaName,ordernum AreaKey,id Px from area
union all
select id,schoolname,Areaid,ordernum from school) as 表别名
(select id,province as AreaName,ordernum AreaKey,id Px from area
union all
select id,schoolname,Areaid,ordernum from school) as 表别名
union all
select id,schoolname,Areaid,ordernum from school
(
select id,province as AreaName,ordernum AreaKey,id Px from area
union all
select id,schoolname,Areaid,ordernum,'' from school
) tt
--(1)你犯了2个错误一个是使用union all连接2个表的时候,2个表的数量必须一致
--(2)union all之后组成新的表在查询,表后面要表别名
(
select id,province as AreaName,ordernum AreaKey,id Px from area
union all
select id,schoolname,Areaid,ordernum from school
) tt