Skip to main content

FIRST_SIGNIFICANT_SUBDOMAIN

Description​

Syntax​

VARCHAR first_significant_subdomain(VARCHAR url)

Extract the "first valid subdomain" from a URL and return it. If the URL is invalid, return an empty string.

Example​

mysql [(none)]>select first_significant_subdomain("www.baidu.com");
+----------------------------------------------+
| first_significant_subdomain('www.baidu.com') |
+----------------------------------------------+
| baidu |
+----------------------------------------------+

mysql [(none)]>select first_significant_subdomain("www.google.com.cn");
+--------------------------------------------------+
| first_significant_subdomain('www.google.com.cn') |
+--------------------------------------------------+
| google |
+--------------------------------------------------

mysql [(none)]>select first_significant_subdomain("wwwwwwww");
+-----------------------------------------+
| first_significant_subdomain('wwwwwwww') |
+-----------------------------------------+
| |
+-----------------------------------------+

Keywords​

FIRST_SIGNIFICANT_SUBDOMAIN