Remove all non-numeric characters from a field

后端 未结 4 660
失恋的感觉
失恋的感觉 2020-12-17 18:16

I have a results set from a webform that includes a phone number for each set. the format of this phone number is not enforced (some are xxxxxxxxxx, some are (xxx)xxx-xxxx a

4条回答
  •  醉梦人生
    2020-12-17 18:51

    On MySQL 8.0+ there is a new native function called REGEXP_REPLACE. A clean solution to this question would be:

    update table set data = REGEXP_REPLACE(data, '[^0-9]+', "") where condition
    

提交回复
热议问题