xxxxxxxxxx
UPDATE MY_TABLE AS t1
INNER JOIN MY_OTHER_TABLE AS t2 ON t1.COLID = t2.COLID
SET t1.COL1 = t2.COL1, t1.COL2 = t2.COL2
WHERE t1.COL3 = 'OK';
xxxxxxxxxx
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'
xxxxxxxxxx
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'
xxxxxxxxxx
UPDATE user_stock SET user_stock1 = user_stock2
WHERE user_stock1 IS NULL AND user_id = 'mike';
UPDATE user_stock SET user_stock1 = "any value"
WHERE user_stock1 IS NULL AND user_id = 'mike';
xxxxxxxxxx
/* Update products position by it's brand's position (from options table)
with Considering the languages */
UPDATE products
INNER JOIN options ON products.brand = options.value
SET products.brand_position = IF(options.lang = products.lang, options.position, products.brand_position)
WHERE options.name = 'pro_brand';