Actions

MySQL SQL insert data from another table lookup

From zen2

Revision as of 03:19, 14 April 2016 by Chris (talk | contribs)
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