1、mysql中update中嵌套select
update A inner join(select id,name from B) c on A.id = c.id set A.name = c.name;
2、msql中的update嵌套条件判断
#更改金属量,品位,矿石量
UPDATE
nm_mining_reserves_associated_elements
set
ore_quantity_total = ore_quantity_proven + ore_quantity_probable,
amount_proven = (
CASE
WHEN associated_elements_name = '金' or associated_elements_name ='银' THEN ore_quantity_proven * grade_proven / 1000000
ELSE ore_quantity_proven * grade_proven / 100
END
),
amount_probable = (
CASE
WHEN associated_elements_name = '金' or associated_elements_name ='银' THEN ore_quantity_probable * grade_probable / 1000000
ELSE ore_quantity_probable * grade_probable / 100
END
),
amount_total = amount_proven + amount_probable,
grade_total = (
CASE
WHEN associated_elements_name = '金' or associated_elements_name ='银' THEN amount_total * 1000000 / ore_quantity_total
ELSE amount_total * 100 / ore_quantity_total
END
)