duplicates - mysql modify duplicated fields -
i have table (products) duplicate products_model field . need change them new value. can select them: select * products group products_model having count(*) >=2
i need change products_model = products_model + random number
thank you
given both fields varchars job, concatenating products_model , products_id underscore
update products p1, products p2 set p1.products_model = concat(p1.products_model, '_', p1.products_id), p2.products_model = concat(p2.products_model, '_', p2.products_id) p1.products_model = p2.products_model , p1.products_id > p2.products_id
before:
id products_model products_id 1 2 b 3 b 4 c 5 c b
after:
id products_model products_id 1 a_a 2 a_b b 3 b 4 c_a 5 c_b b
Comments
Post a Comment