繁体   English   中英

MySQL使用RLIKE表达式删除查询

[英]MySQL Delete Query With RLIKE Expression

我试图运行查询以基于表达式删除重复项。 我要使用的表达方式是这个。

category-23023category-link-2398category-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]+$';

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM