如何将行从一个表插入另一个表.. [英] how to insert row from one table to another..

查看:133
本文介绍了如何将行从一个表插入另一个表..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何将table1的行插入table2 ..并在插入后从table1删除该行。

how i insert row of table1 to table2 ..and after insertion delete that row from table1.

推荐答案

在这里你可以检查

如果你的两个表具有相同的定义意味着相同数量的列和相同的数据类型

那么你可以使用

Here you can check
if your both tables having same defination means same number of columns and same data types
then you can go with
insert into table2
select * from table1 where id=1 --your condition here
delete from table1 where id=1 --your condition here



如果您的两个表格定义不同但受尊重列的数据类型必须相同

那么你n eve>


if your both table defination are different but the datatype of respected columns must be same
then you need to go for

insert into table2
select column1,column2,column3 from table1 where id=1 --your condition here
delete from table1 where id=1 --your condition here
--where column1,column2 and column3 are the columns you need to take from table1 which need to be inserted into table2



< br $>


谢谢

快乐编码;>)




Thanks
Happy coding ;>)


这篇关于如何将行从一个表插入另一个表..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆