mysql - 如何在MySQL中用 "%"替换数字字符?

标签 mysql

如何在 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/

相关文章:

MySQL转换为日期时间语法错误: unexpected IDENT_QUOTED

php - MySQL PHP 将查询中的单词与数据库列匹配

mysql - mySQL createTable 方法中的数字是什么意思?

MYSQL查询比较2个表的值

php - 我们在处理 session 时必须使用 mysql_real_escape_string() 吗?

python - 基于FK的Django查询——get all,not any

mysql - 类型错误 : Cannot read property 'filename' of undefined--multer

java - 错误: incompatible types: int cannot be converted to Client - Java

MySQL:当列 "foo"早于 2015-01-01 时更新列 "job_date"

c++ - mysql_query() 很慢