插入子查询以将数据从一个表传输到另一个表 [英] insert sub query for data transfer from one table to another

查看:90
本文介绍了插入子查询以将数据从一个表传输到另一个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个桌子

表-1:客户名称,客户名称,客户名称,城市,电话,密码
表2:客户编号,订单编号,订单日期,金额



我想将table-1.custid值插入到table-2.custid中

表1中有数据
表2为空白


如何编写查询以将数据插入表2中?
请帮助.

解决方案

尝试一下,



 插入 插入 table-2(custid)  

谢谢.


亲爱的尼克希尔,

使用过程将客户ID插入到表1中,并通过将客户ID作为out参数返回该客户ID.

然后,您将获得Customer ID的那一刻,将其保存在某个变量中,并用于将其插入到table2中.

如果可以帮助您,请将此标记为您的答案.

谢谢


i am having two table

table-1 :custid,custname,custadd,city,phone,pin
table-2 :custid,orderid,orderdate,amount



i want to insert table-1.custid values into table-2.custid

table-1 is having the data
table-2 is blank


how do i write the query to insert data into table-2 ?
plz Help.

解决方案

Try this,



insert into table-2(custid) select custid from table-2



Thanks..


Dear Nikhil,

Use procedure which returns the Customer ID the moment it is inserted into the table1 by using the CustomerID as the out parameter.

Then the moment you will get the Customer ID save it in some variable and use it for inserting the same into table2.

Please mark this as your answer if this helps you out.

Thanks


这篇关于插入子查询以将数据从一个表传输到另一个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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