TOP_LEVEL_DOMAIN
Descriptionβ
Syntaxβ
VARCHAR top_level_domain(VARCHAR url)
Extract the top-level domain from a URL and return it. If the URL is invalid, return an empty string.
Exampleβ
mysql [(none)]>select top_level_domain("www.baidu.com");
+-----------------------------------+
| top_level_domain('www.baidu.com') |
+-----------------------------------+
| com |
+-----------------------------------+
mysql [(none)]>select top_level_domain("www.google.com.cn");
+---------------------------------------+
| top_level_domain('www.google.com.cn') |
+---------------------------------------+
| cn |
+---------------------------------------+
mysql [(none)]>select top_level_domain("wwwwwwww");
+------------------------------+
| top_level_domain('wwwwwwww') |
+------------------------------+
| |
+------------------------------+
keywordsβ
top_level_domain