mysql: get domain name from url string

by prettyscripts on 2009-02-13 12:46:09

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.
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 />)
(For my next comment on this site)
(Allow users to contact me through a message form -- Your email will not be revealed!)