Update rows in Table A from values of Table B in MySQL
Filed Under (General) by Wenbert on 14-02-2008
Tagged Under : MySQL
Sometimes, we need to update values of tables from the values from another table. Here is an example:
-
-
UPDATE `transactions` t , `tran_daily` daily
-
SET
-
t.col_manager = daily.Col_manager,
-
t.invoice_date = daily.Invoice_date,
-
t.due_date = daily.Due_date,
-
t.po_no = daily.Po_no,
-
t.remark = daily.Remark,
-
t.gross_amount = daily.Gross_amount,
-
t.adjustments = daily.Adjustments,
-
t.open_amount = daily.Open_amount,
-
t.bill_to = daily.Bill_to
-
-
WHERE
-
t.company = daily.Company AND
-
t.trans_type = daily.Trans_type AND
-
t.invoice_no = daily.Invoice_no AND
-
t.line_no = daily.Line_no