我想从表:attribute_lang 中删除重复的名称。 另外,使用 id_attribute 更新 Product_attribute 表。 请帮忙解决sql问题。
表:attribute_lang
id_attribute,name
1,15
2,16
3,15 -> remove
4,16 -> remove
表:产品属性
id_product,id_attribute
12,1
13,2
14,3 -> change id_attribute to 1
15,4 -> change id_attribute to 2
最佳答案
首先您必须更新您的产品
update product_attribute
set id_attributte = 2
where id_product = 15
update product_attribute
set id_attributte = 1
where id_product = 14
然后删除重复的
delete from attribute_lang
where id_atributte in(3,4)
关于mysql - Sql (mariadb) 删除重复名称并更新其他表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49706872/