i am having some list of domains in the DB,like
http://www.masn.com/index.html
http://www.123musiq.com/index.html
etc
w
Based on these answers, I came up with a similar solution, but it requires multiple queries.
SELECT SUBSTRING_INDEX(url,'/',1) FROM table WHERE url NOT REGEXP '^[^:]+://';
SELECT SUBSTRING_INDEX(url,'/',3) FROM table WHERE url REGEXP '^[^:]+://';
The first query handles URLs without a protocol prefix. The second query handles URLs with a protocol prefix. Please note that these do not handle every valid URL, but should handle most proper URLs.