Postgres Check if IP (inet) is included in the list of IP ranges

I want to check if an IP address exists in a range of ranges, for example: SELECT * FROM ip_address WHERE ip IN (<list of ip ranges>)

The Postgresql documentation states the use of the <operator to check if the IP is contained within the same IP range, for example: inet '192.168.1.5' << inet '192.168.1/24'but I'm not sure how to use it in the list of ranges without creating an OR chain from <<.

+4
source share
1 answer
select inet '192.168.1.5' << any (array['192.168.1/24', '10/8']::inet[]);
 ?column? 
----------
 t

http://www.postgresql.org/docs/current/static/functions-comparisons.html#AEN18486

+8
source

All Articles