MySQL 删除带有 RLIKE 表达式的查询
MySQL Delete Query With RLIKE Expression
我正在尝试运行查询以根据表达式删除重复项。我想用的表达方式是这样的。
category-23023
或 category-link-2398
或 category-link-url-58693435
基本上,我需要一个表达式来检查 -
短划线符号之前的字符串是否包含一个字母表,后跟一个短划线,最后是一个数字。这是我上次尝试的方法,但没有用。
delete
from core_url_rewrite using core_url_rewrite,
core_url_rewrite e1
where core_url_rewrite.url_rewrite_id > e1.url_rewrite_id
and core_url_rewrite.target_path = e1.target_path
and core_url_rewrite.target_path RLIKE '^[a-z]+\-[0-9]$';
试试这个,应该有用。
delete
from core_url_rewrite using core_url_rewrite,
core_url_rewrite e1
where core_url_rewrite.url_rewrite_id > e1.url_rewrite_id
and core_url_rewrite.target_path = e1.target_path
and core_url_rewrite.target_path RLIKE '^[a-z]+\-*.*\-[0-9]+$';
我似乎可以通过稍微修改 Riad 的代码来实现它。
delete
from core_url_rewrite using core_url_rewrite,
core_url_rewrite e1
where core_url_rewrite.url_rewrite_id > e1.url_rewrite_id
and core_url_rewrite.target_path = e1.target_path
and core_url_rewrite.target_path RLIKE '[a-z]+\-[0-9]+$';
我正在尝试运行查询以根据表达式删除重复项。我想用的表达方式是这样的。
category-23023
或 category-link-2398
或 category-link-url-58693435
基本上,我需要一个表达式来检查 -
短划线符号之前的字符串是否包含一个字母表,后跟一个短划线,最后是一个数字。这是我上次尝试的方法,但没有用。
delete
from core_url_rewrite using core_url_rewrite,
core_url_rewrite e1
where core_url_rewrite.url_rewrite_id > e1.url_rewrite_id
and core_url_rewrite.target_path = e1.target_path
and core_url_rewrite.target_path RLIKE '^[a-z]+\-[0-9]$';
试试这个,应该有用。
delete
from core_url_rewrite using core_url_rewrite,
core_url_rewrite e1
where core_url_rewrite.url_rewrite_id > e1.url_rewrite_id
and core_url_rewrite.target_path = e1.target_path
and core_url_rewrite.target_path RLIKE '^[a-z]+\-*.*\-[0-9]+$';
我似乎可以通过稍微修改 Riad 的代码来实现它。
delete
from core_url_rewrite using core_url_rewrite,
core_url_rewrite e1
where core_url_rewrite.url_rewrite_id > e1.url_rewrite_id
and core_url_rewrite.target_path = e1.target_path
and core_url_rewrite.target_path RLIKE '[a-z]+\-[0-9]+$';