Updating a column from another's repeatable values
I have the following table
Invoice
+++++++++++++++++++++++++++
+ InvoiceId + InvoiceDate +
+开发者_开发技巧++++++++++++++++++++++++++
+ int + int +
+++++++++++++++++++++++++++
InvoiceLine
++++++++++++++++++++++++++++++++++++++++++++
+ InvoiceLineId + InvoiceId + InvoiceDate +
++++++++++++++++++++++++++++++++++++++++++++
+ int + int + int +
++++++++++++++++++++++++++++++++++++++++++++
I recently added the last (InvoiceDate) column to the table and I would like to update it's values with the corresponding values from the Invoice table. For every InvoiceId that matches in both tables, the InvoiceDate should be added to InvoiceLine.
If more input is needed don't hesitate to ask.
Update InvoiceLine
Set InvoiceDate = Invoice.InvoiceDate
From Invoice inner join InvoiceLine on Invoice.InvoiceId = InvoiceLine.InvoiceId
maybe something like this?
update detail
set invoicedate = summary.invoicedate
from invoiceline detail
inner join invoice summary
on summary.invoiceid = detail.invoiceid
精彩评论