Mysql query to extract domains from urls

前端 未结 12 2153
小鲜肉
小鲜肉 2020-12-08 08:21

sorry for my english

i have this query to extract domain from urls

SELECT SUBSTRING(LEFT(url, LOCATE(\'/\', url, 8) - 1), 8) AS domain...
         


        
12条回答
  •  不知归路
    2020-12-08 08:33

    If you want to remove www. along with http://, https:// and /(path) from your domain please do this:

    SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING_INDEX(document_url, '/', 3), '://', -1), '/', 1), '?', 1),'www.',-1)
    

提交回复
热议问题