We have already seen, How to split string in MySQL query in my previous post. Now I like to expand this with more worth thinks by doing. Lets consider task to split the string between two characters in mysql.
How to get split the tld from url
below example will describe how to extract tld in mysql from website URL or domain.
Task: getting the tld from url.
Sample Data table
|website name||website Url|
|Wild into the society||http://wild-into-the-society.blogspot.in/|
SELECT CONCAT('.',SUBSTRING_INDEX(SUBSTRING_INDEX(website_url,'/',3),'.',-1)) tld from website
okay we got it now, I think lets go little further. we may to exclude the few domain when we find the countries. here we see how to do that. I am going to exclude the blog spot websites when I from extract query
SELECT CONCAT('.',SUBSTRING_INDEX(SUBSTRING_INDEX(website_url,'/',3),'.',-1)) tld from website where LOCATE('.blogspot.',website_url) = 0