Обсуждение: operator contains in older Pgsql
I need a functionality of "@>" array operator in 8.1 Pg server. i.ex. SELECT * FROM table WHERE array_col @> ARRAY ['xxx'] (works in 8.2, error in 8.1) How to performe such a query ? Is it possible ? Thanks for help.
On 2009-08-18, W. Kinastowski <kinastowski@gmail.com> wrote: > I need a functionality of "@>" array operator in 8.1 Pg server. i.ex. > SELECT * FROM table WHERE array_col @> ARRAY ['xxx'] (works in 8.2, > error in 8.1) > How to performe such a query ? Is it possible ? Thanks for help. SELECT * FROM table WHERE 'xxx' = ANY( array_col )
Jasen Betts wrote: > On 2009-08-18, W. Kinastowski <kinastowski@gmail.com> wrote: > >> I need a functionality of "@>" array operator in 8.1 Pg server. i.ex. >> SELECT * FROM table WHERE array_col @> ARRAY ['xxx'] (works in 8.2, >> error in 8.1) >> How to performe such a query ? Is it possible ? Thanks for help. >> > > SELECT * FROM table WHERE 'xxx' = ANY( array_col ) > > > thanks, it works ... and when there is more elements in array: i.ex SELECT * FROM table WHERE array_col @> ARRAY ['xxx', 'yyy'] i need to SELECT * FROM table WHERE 'xxx' = ANY( array_col ) AND 'yyy' = ANY( array_col ) is that correct ?
On 2009-08-18, W. Kinastowski <kinastowski@gmail.com> wrote: > Jasen Betts wrote: >> On 2009-08-18, W. Kinastowski <kinastowski@gmail.com> wrote: >> >>> I need a functionality of "@>" array operator in 8.1 Pg server. i.ex. >>> SELECT * FROM table WHERE array_col @> ARRAY ['xxx'] (works in 8.2, >>> error in 8.1) >>> How to performe such a query ? Is it possible ? Thanks for help. >>> >> >> SELECT * FROM table WHERE 'xxx' = ANY( array_col ) >> >> >> > thanks, it works ... and when there is more elements in array: i.ex > SELECT * FROM table WHERE array_col @> ARRAY ['xxx', 'yyy'] > i need to > SELECT * FROM table WHERE 'xxx' = ANY( array_col ) AND 'yyy' = ANY( > array_col ) > is that correct ? it looks good it to me.