如何使用其他表键在表中插入多个记录 [英] how to insert multiple records in a table using other table key
问题描述
我有两张桌子
一张是invoicedetails,另一张是productdetails
invoicedetails有(invoiceid,invoiceno,firmname和发票日期) )表格中的字段和发票ID是主键
和productdetails有(产品,名称,描述,数量,价格和发票) productid是主键的字段,invoiceid是关于invoicetable的foriegn键
现在我想在productdetails表中使用单一发票ID插入多个产品详细信息我怎么能实现任何人都可以帮助我
i have two table
one is invoicedetails and another one is productdetails
invoicedetails have (invoiceid,invoiceno,firmname and invoice date)field in table and invoice id is primary key
and productdetails have (productid,name,description,qty,price and invoiceid)field where productid is primary key and invoiceid is foriegn key with respect to invoicetable
now i want to insert multiple product details in productdetails table using single invoice id how could i achieve that can any one help me
推荐答案
只需使用INSERT命令添加多行,每行都有相同的InvoiceId参考。
那你就是使用JOIN或WHILE子句拉出适当的记录。
Just use INSERT commands to add multiple rows, each with the same InvoiceId reference.
Then you just pull the appropriate records using a JOIN or WHILE clause.
这篇关于如何使用其他表键在表中插入多个记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!