📜  mysql 使用另一个表中的值更新列 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:04:57.435000             🧑  作者: Mango

代码示例2
/* 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';