douzai6337 2015-02-13 19:50
浏览 39
已采纳

Sql substring_index删除非永久链接地址

I'm trying to get all the results in my database that match a specific query.

Right now the way I have it is basically selecting only the root domain.

For example I have in my database:

www.website.com/hello www.website.com/

I only select www.website.com/ right now but instead I want to select only domains that have something after the slash (/) and display them in a table.

Here is my code - I tried adding things before and after the '/' and playing around with the number '3' or '-3' but nothing gives me the result I want.

SELECT SUBSTRING_INDEX(url, '/', 3) FROM crawldomains;
  • 写回答

1条回答 默认 最新

  • duan0065626385 2015-02-13 19:54
    关注

    You can try this:

    SELECT url FROM crawldomains WHERE `url` RLIKE '^(http://|https://)?.*\\..*/.+$'
    

    I hope this helps.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?