在2个表格中插入数据 [英] insert data in 2 tables

查看:103
本文介绍了在2个表格中插入数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个表,一个是注册第二个,是登录名,我想同时插入两个表中的数据,这意味着使用单个查询数据插入2个表中.

i have 2 tables one is sign up second is login i want to insert data both tables simultaneously mean using single query data insert in 2 tables.

推荐答案

AFAIK ,对于单个插入,只能有一个insert语句.单个插入语句不能在两个表中插入,但是,可以为登录表在Signup表上创建一个插入触发器.

因此,当将数据插入到Signup表中时,它将自动在登录表中触发插入.
AFAIK, for single insert there can be only one insert statement. Single insert statement cannot insert in two tables, however, you can create an insert Trigger on Signup table for login table.

So when the data is inserted in Signup table, it will automatically fire insert in login table.


您不能通过单个插入查询在两个表中插入记录,可以按建议使用触发器通过Amit或可以参考以下内容:

http://www.hiteshagrawal.com/mysql/mysql-batch-insert-using-php [ ^ ]

希望这会有所帮助:)
you can not insert records in two tables with a single insert query, you can use trigger as suggested by Amit or can refer this:

http://www.hiteshagrawal.com/mysql/mysql-batch-insert-using-php[^]

hope this helps :)


这篇关于在2个表格中插入数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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