lundi 20 avril 2015

Filter rows if array contains value in a given range

I have a PostgreSQL table with a column timeslot which is an int array. I need to make a query that returns rows whose timeslot contains at least one number within a specified range. Alternatively, it could return rows whose timeslot contains values greater than 0. Right now, my query looks like this:

SELECT * FROM shows WHERE timeslot @> ARRAY[167], which will only return items from shows whose timeslot contains 167, when what I really need is something like:

SELECT * FROM shows WHERE timeslot @> 0-167, or

SELECT * FROM shows WHERE timeslot @> >0

Aucun commentaire:

Enregistrer un commentaire