Sql Replace

I need a mysql syntax to change existing product code from"123" to "abc"

1. 123 to abc

2. 234 to dsx




1500. 34567 to adcsx

All 578 products change code from kl1235 to kis-12-5-ln. Diferent code for all 578 make in one update.

If you know the to/from pattern, you can use mySQL internal functions like 'replace', 'concat', etc. But it will be a challenge to update 578 with one SQL query. Suggest you do something (not complete) like:

echo "
foreach(db_get_fields("SELECT product_code FROM ?:products) as $cur_product_code) {
  $new_code = my_magic_translation($cur_product_code);
  db_query("UPDATE ?:products SET product_code=?s WHERE product_code=?s", $new_code, $cur_product_code);
  printf("%s => %s\n", $cur_product_code, $new_code);

You'll have to write the 'my_magic_translation() function to match patterns and return appropriate (and unique) results.