How can i get only the subdomains and main domains in technology table?
Thanks =)
Hi @yajavu. Could you elaborate on what you’re looking for? What do you mean by subdomains and domains?
Yes i do. For example the urls in technologies tables contain domains and subdomains. When i get a row i want to know if it is a subdomain or not (like if it is a maps.google.com or (www.)google.com)
Ah ok. Here’s a little utility function you can use to identify whether a URL has a subdomain or not, using the NET.REG_DOMAIN built-in function to get the URL’s domain:
#standardSQL
CREATE TEMP FUNCTION hasSubdomain(url STRING) RETURNS BOOLEAN AS (
NOT ENDS_WITH(url, CONCAT('//', NET.REG_DOMAIN(url), '/'))
);
SELECT
hasSubdomain('https://maps.google.com/'), # true
hasSubdomain('https://www.google.com/'), # true
hasSubdomain('https://google.com/') #false
You could include and call that function in your technology query. Let me know if that’s what you’re looking for.
1 Like
Great thank you very much!