开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜