本文介绍了从另一个表中分配表中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嘿大家。 我正在用c#开发一个应用程序,你可以将文本框中的值插入到两个不同的MYSQL表中。在表1中,我有一个employeeid,它在创建新记录时自动递增。在表2中,我有一个同名的字段,我想从table1中为它分配相应的id。我不知道该怎么做。我是否使用加入? 非常感谢任何建议
Hey everyone. I am developing a application in c# where you insert values from textboxes to two different MYSQL tables. In table 1 I have a employeeid which is auto incremented when a new record is created. In table 2 I have a field of the same name and I want to assign it the corresponding id from table1. I''m not sure how to do this. Do I use a join?? Any advice would be very much appreciated
推荐答案我相信MySQL LAST_INSERT_ID()会给你最后一个ID。因此,如果您有2个插入语句,则在第一个插入到table1之后将LAST_INSERT_ID()存储到变量中,然后使用该变量插入到表2中。 I believe in MySQL LAST_INSERT_ID() will give you the last ID. So, if you had 2 insert statements, after the first one which inserts into table1 store LAST_INSERT_ID() into a variable and then use that variable to insert into table 2.
更多推荐
从另一个表中分配表中的值
发布评论