Reputation: 525
I have a table that contains two cidr arrays. One contains hosts ip addresses and the second one network addresses.
I need to write a function that would execute query like this:
SELECT * from sometable
WHERE ip_addr IN( 'all items from first array') OR
ip_addr << 'all item from second array'
So basically I need to search records which ip_addr equals to one from the first array or ip_addr is contained within one of the networks from the second array.
Upvotes: 2
Views: 2342
Reputation: 399
If I understand you correctly, you're looking for the ANY
comparison function
SELECT *
FROM sometable
WHERE ( ip_addr = ANY ('all items from first array')
OR ip_addr << ANY ('all item from second array')
)
Upvotes: 3