
SQL语句 怎么把从一个表中查出来数据插入到另一个表中
13个回答
展开全部
insert into tableA (col1,col2, col3)
(
select tableB.col1, tableB.col2, tableB.col3
from tableB
where ...
)
(
select tableB.col1, tableB.col2, tableB.col3
from tableB
where ...
)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
insert into T_annual(year,userid,username) select hryear,userid,username from T_annualleavebase where ...
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
以下:
1、
insert into A([id], ids, [name], type, time)
select [id], null, [name], 'dd', getdate() from B where type='dd'
2、
DECLARE @num int,@i int;
SET @i=0;
SET @num=(select 字段 from 表1 where 条件);
WHILE @i<@num
begin
set @i=@i+1;
insert INTO 表2(字段) SELECT 字段 from 表1 where 条件;
end;
3、
insert into b (column1,datecolumn)
select column1,getdate() from a
1、
insert into A([id], ids, [name], type, time)
select [id], null, [name], 'dd', getdate() from B where type='dd'
2、
DECLARE @num int,@i int;
SET @i=0;
SET @num=(select 字段 from 表1 where 条件);
WHILE @i<@num
begin
set @i=@i+1;
insert INTO 表2(字段) SELECT 字段 from 表1 where 条件;
end;
3、
insert into b (column1,datecolumn)
select column1,getdate() from a
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询