A web developer's blog. PHP, MySQL, CakePHP, Zend Framework, Wordpress, Code Igniter, Django, Python, CSS, Javascript, jQuery, Knockout.js, and other web development topics.

Update rows in Table A from values of Table B in 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
            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
            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
This entry was posted in General and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>