Extract Subdomain
This function extracts the sub-domain from a URL. This function will use the public suffix list to extract the TLD. Check the Extracting The Main Domain section for more information about the public suffix list.
D SELECT extract_subdomain('http://a.b.example.com/path') AS dns_record;
ββββββββββββββ
β dns_record β
β varchar β
ββββββββββββββ€
β a.b β
ββββββββββββββ
D SELECT extract_subdomain('test.example.com.ac') AS dns_record;
ββββββββββββββ
β dns_record β
β varchar β
ββββββββββββββ€
β test β
ββββββββββββββLast updated
Was this helpful?