我有下表
发票
+++++++++++++++++++++++++++
+ InvoiceId + InvoiceDate +
+++++++++++++++++++++++++++
+ int + int +
+++++++++++++++++++++++++++
InvoiceLine
++++++++++++++++++++++++++++++++++++++++++++
+ InvoiceLineId + InvoiceId + InvoiceDate +
++++++++++++++++++++++++++++++++++++++++++++
+ int + int + int +
++++++++++++++++++++++++++++++++++++++++++++
我最近将最后一个(InvoiceDate)列添加到表中,我想用Invoice表中的相应值更新它的值。对于在两个表中匹配的每个InvoiceId,InvoiceDate应添加到InvoiceLine。
如果需要更多输入,请不要犹豫。
答案 0 :(得分:0)
也许是这样的?
update detail
set invoicedate = summary.invoicedate
from invoiceline detail
inner join invoice summary
on summary.invoiceid = detail.invoiceid
答案 1 :(得分:0)
Update InvoiceLine
Set InvoiceDate = Invoice.InvoiceDate
From Invoice inner join InvoiceLine on Invoice.InvoiceId = InvoiceLine.InvoiceId