MySQL: Get domain name from url string

I need to run a report of URLs stored in mysql database which shows the domain and the count. How to extract the domain or subdomin from the full url string with mysql?

substring_index(substring_index(trim(leading "https://" from trim(leading http://" from trim(url))), "/", 1), ":", 1)

Leave a Reply

Your email address will not be published. Required fields are marked *