用相同的值替换 2 个字符

Replace 2 characters with same value

我想立即从 A300,0|A232,0

中的相同值中删除 ,0|

测试table

+----+------+---------------------+
| id   | name                  |
+----+------+---------------------+
|  1   | A300,0|A232,0         |
+----+------+---------------------+ 

select REPLACE(t.name, "|", " ") as a,
replace(t.name, ',0', '') as b
from test as t;
result 
a = A300,0 A232,0 
b= A300|A232

如果我没理解错的话,你可以使用 REPLACE 两次来达到你想要的效果:

SELECT REPLACE(REPLACE(t.name, '|', ' '), ',0', '') AS yourResult
FROM test as t;
SELECT REGEXP_REPLACE(name, '(,0)|(\|)', '')
FROM test;

我。只需找到 ,0| 并将找到的所有匹配项替换为空字符串。