好的,说得非常清楚, 我的表格如下所示:
ID post_title post_type
------------------------------------------------------
1 product A product
2 product A - Size S product_variation
3 product A - Size M product_variation
4 product A - Size L product_variation
5 product B product
6 product A - Size S product_variation
7 product A - Size M product_variation
8 product A - Size L product_variation
9 product C product
10 product A - Size S product_variation
11 product A - Size M product_variation
12 product A - Size L product_variation
13 product D product
14 product A - Size S product_variation
15 product A - Size M product_variation
16 product A - Size L product_variation
我想成为这样的人:
ID post_title post_type
------------------------------------------------------
1 product A product
2 product A - Size S product_variation
3 product A - Size M product_variation
4 product A - Size L product_variation
5 product B product
6 product B - Size S product_variation
7 product B - Size M product_variation
8 product B - Size L product_variation
9 product C product
10 product C - Size S product_variation
11 product C - Size M product_variation
12 product C - Size L product_variation
13 product D product
14 product D - Size S product_variation
15 product D - Size M product_variation
16 product D - Size L product_variation
如何更改以 post_type“product”值作为父级的“product_variation”值 post_title。
如果我有大约 1000 个产品,我该如何更改它......?
最佳答案
您可以使用替换功能
update tableName set post_title=REPLACE(post_title,'A','B') where ID in(6,7,8)
关于mysql - SQL - 用条件替换另一个列值中的列值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44115228/