Actions

MySQL SQL insert data from another table lookup

From zen2

Revision as of 02:46, 14 April 2016 by Chris (talk | contribs) (Created page with "<code> UPDATE tableB INNER JOIN tableA ON tableB.name = tableA.name SET tableB.value = IF(tableA.value > 0, tableA.value, tableB.value) WHERE tableA.name = 'Joe'</code> <code...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

UPDATE tableB INNER JOIN tableA ON tableB.name = tableA.name SET tableB.value = IF(tableA.value > 0, tableA.value, tableB.value) WHERE tableA.name = 'Joe'

UPDATE invoice_header INNER JOIN customers ON invoice_header.customer_id = customers.id SET invoice_header.name = customers.name, invoice_header.company = customers.company, invoice_header.address = customers.address WHERE 1