如何通过访问Primar表中的外键字段名称来插入外键字段ID [英] How Do I Insert A Foreign Key Field Id By Accessing Foreign Key Field Name In Primar Table

查看:75
本文介绍了如何通过访问Primar表中的外键字段名称来插入外键字段ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hiii ..



我在帐户表中插入一条记录,在帐户表中有一个表所有者的外键所有者,当时要插入一个记录帐户表我将在帐户表的ownername列中插入所有者名称并且我想将该ownename的ownerid插入到帐户表的ownerid列中

Hiii..

I insert a record in account table,in account table have a foreign key ownerid of table owner ,at the time to insert a record in account table i will insert ownername in ownername column of account table & i want to insert a ownerid of that ownename into ownerid column of account table

推荐答案

这样的事情是不可能的因为你需要首先验证所有者名称是否存在于所有者表下,然后我们可以相应地插入带有所有者的记录。



我建议你去寻找一些存储过程和触发器...如果可以,请提供更多详细信息。
Such thing is not possible as you need to validate the ownername first whether exist under the owner table or not then we could insert the record(s) with ownerid accordingly.

I would suggest you to go for some stored-procedure & trigger to do so...Please provide more details if you can.


这篇关于如何通过访问Primar表中的外键字段名称来插入外键字段ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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