表产品名称
product_id | product_language | product_name
1 en apple pad
1 fr (empty)
2 en apple pod
2 fr (empty)
3 en apple mac
3 fr (empty)
我想创建一个更新查询,将每个product_id的product_name从“en”行复制到(空)product_name字段中具有相同product_id且“fr”的行。
谢谢
最佳答案
update p1
set p1.product_name = p2.product_name
from table_product_name p1
inner join table_product_name p2 on p2.product_id = p1.product_id and p2.product_language = 'en'
where p1.product_language = 'fr'
关于MySql - 使用同一表的某些字段的值更新表的某些字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25404452/