mundos
mundos

Reputation: 459

How to filter a range of IPs in Big Query

I have a table with records (ids) and ip address (ip_addresses) and I want to write a query that returns ids for a range of IPs (between 192.160.1.1 - 192.160.1.100). How would I go about this in BigQuery?

I know I need to use a combination of NET.IPV4_TO_INT64 and NET.IP_FROM_STRING, but I'm not sure exactly how to write this.

Upvotes: 1

Views: 708

Answers (1)

Mikhail Berlyant
Mikhail Berlyant

Reputation: 172993

you can use below to convert IP to INT and then do simple comparison

SELECT NET.IPV4_TO_INT64(NET.IP_FROM_STRING('192.160.1.105'))  

Upvotes: 2

Related Questions