在mysql中与regexp进行match链接

时间:2015-03-19 11:29:19

标签: mysql regex

尝试将链接与正则表达式匹配

SELECT *, COUNT(id) FROM as795_sh404sef_urls WHERE newurl REGEXP 'index\.php\?option\=com\_ohanah&Itemid=108\&id\=\d+\&lang\=en\&view\=event' AND rank<>0 GROUP BY oldurl

但是没有结果。

链接类型

index.php?option=com_ohanah&Itemid=108&id=4778056&lang=en&view=event
index.php?option=com_ohanah&Itemid=108&id=4779002&lang=en&view=event

你能帮我吗?

1 个答案:

答案 0 :(得分:1)

如何使用简单的LIKE,匹配id之前和之后的字符串?

SELECT *, COUNT(id) FROM as795_sh404sef_urls
WHERE newurl LIKE 'index.php?option=com_ohanah&Itemid=108&id=%' AND newurl LIKE '%lang=en&view=event'
AND rank<>0 GROUP BY oldurl