我如何只插入一个唯一键就可以插入多个记录 [英] How can i insert multiple records only single unique key

查看:96
本文介绍了我如何只插入一个唯一键就可以插入多个记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这里,我想仅使用单个ID插入多条记录,例如

订单ID-1
项目总金额
rin 5 29
勒克斯10
车轮2
excel 12

请提供代码或查询此类插入记录.

Here I want to insert more then one records using only single id like

order id-1
item amount total
rin 5 29
lux 10
wheel 2
excel 12

Please give code or query for such type of insert records.

推荐答案

看完最后几个问题后,很明显您还没有学习过ADO.Net的概念.
您在这里提出一些非常基本的问题,这种情况将一直持续到您不学习ADO.Net为止.
我建议您先买一本书,学习ADO.Net的所有概念.
肯定会为您提供帮助.
After looking at your last few questions, its clear that you have not learned concepts of ADO.Net.
You are asking some very basic questions here and this will continue till you don''t learn ADO.Net.
I suggest you to first buy a book and learn all concepts of ADO.Net.
It will definitely help you.


使用一对多关系.创建OrderTable并存储订单详细信息(例如ID和日期等).创建OrderItemTable以存储订单商品"详细信息,在这里您可以引用orderTable中的订单ID来将每个商品与特定订单相关联.

希望这会对您有所帮助:)
Use one-to-many relationship. Create OrderTable and store the orderdetails such as id and date etc. Create OrderItemTable to store the Order Item details , here you can refer the order id from the orderTable to relate each item with a particular order.

Hope this will help you :)


使用唯一键是为了避免重复条目,并且它强制实体完整性作为主键约束,不可能有多个记录使用单个唯一键.
uses of unique key is to avoid duplicate entries and it enforce entity integrity as the primary key constraints, more than one record with single unique key is not possible.


这篇关于我如何只插入一个唯一键就可以插入多个记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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