sql查询从记录中删除“/”斜杠

时间:2014-05-26 17:08:18

标签: mysql database

我的数据库中有一些条目要从斜杠char中清除,如下所示:

text-/-moreText

我想升级到:

text-moreText

我试过了:

SELECT * FROM myTable WHERE `column` LIKE BINARY '%\/%'

此查询适用于以下字符:但不包含/

1 个答案:

答案 0 :(得分:0)

replace()应该可以做到

update 
myTable
set col = replace(col,'/','');


mysql> select replace('text-/-moreText','/','');
+-----------------------------------+
| replace('text-/-moreText','/','') |
+-----------------------------------+
| text--moreText                    |
+-----------------------------------+
1 row in set (0.00 sec)

mysql> select replace('text--moreText','/','');
+----------------------------------+
| replace('text--moreText','/','') |
+----------------------------------+
| text--moreText                   |
+----------------------------------+
1 row in set (0.00 sec)