Possible Duplicate:
How we can find domain name using MySQL and regular expression
My db table has a column called url which contains info like: http://xyz.com/cat/index/?page=2 http://www.google.com/webmaster.php http://yahoo.com/dsdsd/category.aspx etc.
I want to just fetch their domain names like: xyz.com google.com yahoo.com
How should I write the query in mysql to get the above result.
Please help.
Someone in Digital Point gave me the answer
SELECT SUBSTRING_INDEX(REPLACE(REPLACE(url, "http://", ""), "www.", ""), '/', 1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With