简体   繁体   中英

How to remove specific number in string that is in random order?

Lets say that I have data rows that look like this:

+----------------------------+
+   test_table               +
+----+--------+--------------+
+ id + word   + updated_word +
+----+--------+--------------+
+ 1  + g00gle + ggle         +
+ 2  + bread0 + bread        +
+ 3  + 0bject + bject        +
+ 4  + d0d0   + dd           +
+-------------+--------------+

What statement could I use to take out the zeroes in the word column, so that it looks like the updated_word column? I thought of using substring, but didn't know how to proceed after that.

try:

UPDATE test_table 
SET word = REPLACE(word, '0', '');

replace the 2nd blank '' with anything you want to change with.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM