简体   繁体   中英

Insert multiple values for single foreign key field from one table into another table

here i hav 2 tables

tbl_slaUpdate
tbl_eslaUser

IN tbl_slaUpdate has

SlaId as uniqueidenfier as primarykey

and it already have some values

IN tbl_eslaUser has

userid as uniqueidentifier as primarykey
and username and
slaId as Foreign key as uniqueidentifier

here i have to insert multiple UserId and username into single slaid actualy im getting the username from listbox where the gridview is selected by checkbox

like tbl_eslauser

userid UserName SlaId
1322    robert      1234
1435    jhon        1234
1578    albert      1234

1345    albert     2345
1678    jhon1      2345
1456    robert     2345

1389    robert2    3456
1267    jhon       3456
1568    albert     3456

userid, username and slaId are your real composite Primary Key for tbl_eslaUser. If you don't want to use a composite key, then you would have to add another column of auto increment, and use it as tbl_eslaUser's PK. Either way you would have to change the PK.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM