# How to get subdomains and origins in technologies

**URL:** <https://discuss.httparchive.org/t/how-to-get-subdomains-and-origins-in-technologies/1877>\
**Category:** Uncategorized\
**Created:** [February 24, 2020, 9:17am UTC](https://discuss.httparchive.org/t/how-to-get-subdomains-and-origins-in-technologies/1877 "2020-02-24T09:17:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![yajavu](https://avatars.discourse-cdn.com/v4/letter/y/e495f1/32.png) [@yajavu](https://discuss.httparchive.org/u/yajavu)\
**Post date:** [February 24, 2020, 9:17am UTC](https://discuss.httparchive.org/t/how-to-get-subdomains-and-origins-in-technologies/1877/1 "2020-02-24T09:17:30Z")

</div>

How can i get only the subdomains and main domains in technology table?  
Thanks =)

---

<div class="post-metadata">

**Author:** ![rviscomi](https://yyz1.discourse-cdn.com/flex035/user_avatar/discuss.httparchive.org/rviscomi/32/835_2.png) [@rviscomi](https://discuss.httparchive.org/u/rviscomi)\
**Post date:** [February 25, 2020, 4:48pm UTC](https://discuss.httparchive.org/t/how-to-get-subdomains-and-origins-in-technologies/1877/2 "2020-02-25T16:48:54Z")

</div>

Hi @yajavu. Could you elaborate on what you’re looking for? What do you mean by subdomains and domains?

---

<div class="post-metadata">

**Author:** ![yajavu](https://avatars.discourse-cdn.com/v4/letter/y/e495f1/32.png) [@yajavu](https://discuss.httparchive.org/u/yajavu)\
**Post date:** [February 26, 2020, 8:16am UTC](https://discuss.httparchive.org/t/how-to-get-subdomains-and-origins-in-technologies/1877/3 "2020-02-26T08:16:56Z")

</div>

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](http://maps.google.com) or (www.)[google.com](http://google.com))

---

<div class="post-metadata">

**Author:** ![rviscomi](https://yyz1.discourse-cdn.com/flex035/user_avatar/discuss.httparchive.org/rviscomi/32/835_2.png) [@rviscomi](https://discuss.httparchive.org/u/rviscomi)\
**Post date:** [February 26, 2020, 6:17pm UTC](https://discuss.httparchive.org/t/how-to-get-subdomains-and-origins-in-technologies/1877/4 "2020-02-26T18:17:33Z")

</div>

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:

```sql
#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.

---

<div class="post-metadata">

**Author:** ![yajavu](https://avatars.discourse-cdn.com/v4/letter/y/e495f1/32.png) [@yajavu](https://discuss.httparchive.org/u/yajavu)\
**Post date:** [February 26, 2020, 7:14pm UTC](https://discuss.httparchive.org/t/how-to-get-subdomains-and-origins-in-technologies/1877/5 "2020-02-26T19:14:28Z")

</div>

Great thank you very much!
