sql中 union all 急!!!!
答案:6 悬赏:50
解决时间 2021-02-27 21:33
- 提问者网友:两耳就是菩提
- 2021-02-27 16:31
sql中 union all 急!!!!
最佳答案
- 二级知识专家网友:独钓一江月
- 2021-02-27 17:28
这样写会报错:
改为:
select *
into #table_1
from (select * from tab1 union all select * from tab2) as tmp
上面建的是临时表
sqlserver的这样写:
insert into table_1 select *
from (select * from tab1 union all select * from tab2) as tmp
改为:
select *
into #table_1
from (select * from tab1 union all select * from tab2) as tmp
上面建的是临时表
sqlserver的这样写:
insert into table_1 select *
from (select * from tab1 union all select * from tab2) as tmp
全部回答
- 1楼网友:洎扰庸人
- 2021-02-27 23:35
select * from (
select * from tab1 union all select * from tab2
) a
select * from tab1 union all select * from tab2
) a
- 2楼网友:爱难随人意
- 2021-02-27 22:02
上次我写这种语句的时候sql提醒说只要在第一个select查询中使用into就可以了,试过的确可以.我当时用的sql2005,不知道你的是否可以使用.
- 3楼网友:玩家
- 2021-02-27 21:11
select *
into #table_1
from (select * from tab1 union all select * from tab2) as tmp
上面的tmp随便取的
into #table_1
from (select * from tab1 union all select * from tab2) as tmp
上面的tmp随便取的
- 4楼网友:痴妹与他
- 2021-02-27 20:17
select * from (
select * from tab1
union all
select * from tab2
) as newTableName
----意思就是在你查出的表外围套上一层表,然后取别名
select * from tab1
union all
select * from tab2
) as newTableName
----意思就是在你查出的表外围套上一层表,然后取别名
- 5楼网友:撞了怀
- 2021-02-27 18:51
少个别名吧
select *
into #table_1
from (select * from tab1 union all select * from tab2) t
select *
into #table_1
from (select * from tab1 union all select * from tab2) t
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯