从另一个表中分配表中的值

编程入门 行业动态 更新时间:2024-10-11 05:26:26
本文介绍了从另一个表中分配表中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

嘿大家。 我正在用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.

更多推荐

从另一个表中分配表中的值

本文发布于:2023-07-09 21:13:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1088230.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:分配

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!