如何在 MySQL 中用“%”替换数字字符?
即:abcd 1234 zz => abcd %%%% zz
我有什么:
Declare cursorVideoTitles cursor for select temp_playList.VideoTitle
from temp_playList where temp_playList.VideoTitle regexp '^[A-Za-z0-9]+$';
cursorVideoTitles 包含所有字母数字视频标题。现在在此之后我需要用“%”替换数字字符
原因: 我需要在具有相同字母的其他表中搜索它。 所以首先我获取游标变量中的所有这些值并使用类似的查询对其进行迭代,这样我将获得匹配的记录。
最佳答案
不幸的是,MySQL没有正则表达式替换功能,你必须单独替换每个数字。
SELECT
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(VideoTitle, '0', '%'),
'1', '%'),
'2', '%'),
'3', '%'),
'4', '%'),
'5', '%'),
'6', '%'),
'7', '%'),
'8', '%'),
'9', '%') AS TitleMasked
关于mysql - 如何在MySQL中用 "%"替换数字字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22510619/