开发者

Return records that contain specific string but from the 7th character

开发者 https://www.devze.com 2023-02-08 16:42 出处:网络
I have a mysql field that has text such as \"http://www.example.com/hello.php\" in the \"url\" column.

I have a mysql field that has text such as "http://www.example.com/hello.php" in the "url" column.

I need some sort of mysql query that will allow me to find urls that have two or more slashes. Of course using '%//%' will return all of my urls due to the http:// aspect of the URLs.

So how can I get mysql to only look at u开发者_运维问答rls from the 7th character?


using underscore _ wildcard character to represent the first 7 characters (http://) followed by the pattern you are searching for e.g:

select * from urls where url like '_______%//%'; -- double //

or

select * from urls where url like '_______%/%'; -- single /

or

select * from urls where url like '_______%google%';


Regular expressions ? http://dev.mysql.com/doc/refman/5.1/en/regexp.html - you can do more with this


This should work:

SELECT * FROM table WHERE url LIKE 'http://%//%'


Using regular expressions would be a good way to go.

select * from urls where url regexp '[/].+[/].+[/]';

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号