如何使用存储过程一次将数据保存在两个表中 [英] how ta save data in two table at a time using stored procedure

查看:87
本文介绍了如何使用存储过程一次将数据保存在两个表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用存储过程一次将数据保存在两个表中…….
有两个表注册和buy_product
重复字段是...
id主键自动提示
名称varchar
地址varchar

buy_product字段是...
pid主键自动弹出
id foriegn键
城市varchar


...
现在我想使用存储过程将ID一次插入两个表中,其中ID是自动隐蔽的
你能告诉我我怎么能
........ thanx

how ta save data in two table at a time using stored procedure.......
there are two table registration and buy_product
regitration fields are...
id primary key auto increamnt
name varchar
address varchar

buy_product fields are...
pid primary key auto increament
id foriegn key
city varchar


...
now i want to insert id in both table at a time using stored procedure where id is auto increament
can u tell me how i can
........thanx

推荐答案

只需将您需要在两个表中插入的所有值作为参数传递给存储过程.然后根据需要使用这些参数值.

例如:如果您总共有10个参数值,其中5个值需要进入注册表,而4个值需要进入乘积表,则以正确的值插入相应表的方式来构造插入查询,因此请插入首先使用属于该表的参数值查询您的注册表,然后对产品表进行相同的操作.

让我知道您是否需要进一步的帮助.
Simply pass all the values you need to insert in both the tables as parameters to the store procedure. And then use those paramaters values as per your requirement.

Eg: if you have in total 10 paramater values in which 5 values need to go to registration table and 4 vales to product table , then frame the insert query in such a way that the correct values get inserted in corresponding table, so wrie an insert query first for you registration table using the parameters values belonging to this table and then do the same for product table.

Let me know if you need further help in it.


这篇关于如何使用存储过程一次将数据保存在两个表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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