I'm trying to select rows where a value is present in any of a collection of ranges. So far, I've only been able to make the following work:
SELECT * FROM table
WHERE num <@ numrange(1,4) OR num <@ numrange(7,11)
I was hoping I would be able to get something like
SELECT * FROM table
WHERE num <@ ANY(numrange(1,4), numrange(7,11))
working, but I haven't had any luck with it.
Any idea of a better solution than chaining ORs together?
You were close... The value in the ANY(...)
expression needs to be an array:
SELECT * FROM table
WHERE num <@ ANY(ARRAY[numrange(1,4), numrange(7,11)])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With