如何在LIKE中使用百分比(%)而不将其视为通配符? [英] How to use a percent (%) in a LIKE without it being treated as a wildcard?
问题描述
我有一个应该包含所有顶级域名和第二级域名的数据库.但是我解析的供稿包含很多子文件夹,我想删除其中包含任何%符号的任何行,但是我很难弄清楚如何将百分比符号用作我的字段d喜欢匹配,同时仍在使用LIKE功能.以下是我尝试使用的代码:
I have a database that is supposed to contain all top-level and second-level domain names. But the feed I'm parsing contains a lot of sub folders, I'd like to delete any row that contains any % sign in it, but I am having a hard time figuring out how to use a percent sign as the field I'd like to match, while still using the LIKE feature. Below is the code I'm trying to use:
select FROM `001ProductList` WHERE programURL LIKE '%%%'
以下是我要匹配的示例:
Here is an example of what I'm trying to match:
www.site.com%3Ack-5941560-10463497?url = http%3A%2F%2Fwww.example.com%2Fproddetail.aspx%...
www.site.com%3Ack-5941560-10463497?url=http%3A%2F%2Fwww.example.com%2Fproddetail.aspx%...
如果遇到带有%符号的行,我想将其删除.
If I encounter a row with a % sign in it, I want to delete it.
推荐答案
转义文字%
字符:
select *
FROM 001ProductList
WHERE programURL LIKE '%\%%'
或使用正则表达式
WHERE programURL RLIKE '%'
这篇关于如何在LIKE中使用百分比(%)而不将其视为通配符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!