mysql: get domain name from url string

by prettyscripts on 2009-02-13 12:46:09 • Leave a comment »

code

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)

Tags: domain, sql, string

No feedback yet

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
PoorExcellent
note: all comments are moderated. do not spam and do not advertise. only comments relevant to the post will be published.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)