Arthur Zangiev
Arthur Zangiev

Reputation: 1526

MAtch links with regexp in mysql

Trying to match links with regular expression

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

But returns no results.

The type of links are

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

Can you help me please?

Upvotes: 0

Views: 85

Answers (1)

Oli
Oli

Reputation: 2464

How about using a simple LIKE, that matches both the strings before and after your 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

Upvotes: 1

Related Questions