Mysql query to extract domains from urls

前端 未结 12 2127
小鲜肉
小鲜肉 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:29

    Best to use it as it will also capture url like "www.google.co.in"

    SELECT replace((replace((SUBSTRING_INDEX(SUBSTRING_INDEX(REPLACE(url, '//', ''), '/', 1), '*', -2)), 'http:','')),'https:','') AS Domain
    

提交回复
热议问题