postgresql - Postgres: check if array field contains value? -


i'm sure duplicate question in sense answer out there somewhere, haven't been able find answer after googling 10 minutes, i'd appeal editors not close on basis might useful other people.

i'm using postgres 9.5. table:

        column          │           type            │                                modifiers ─────────────────────────┼───────────────────────────┼─────────────────────────────────────────────────────────────────────────  id                      │ integer                   │ not null default nextval('mytable_id_seq'::regclass)  pmid                    │ character varying(200)    │  pub_types               │ character varying(2000)[] │ not null 

i want find rows "journal" in pub_types.

i've found docs , googled , i've tried:

select * mytable ("journal") in pub_types; select * mytable "journal" in pub_types; select * mytable pub_types=any("journal"); select * mytable pub_types in ("journal"); select * mytable where pub_types contains "journal"; 

i've scanned the postgres array docs can't see simple example of how run query, , stackoverflow questions seem based around more complicated examples.

this should work:

select * mytable 'journal'=any(pub_types); 

i.e. syntax <value> = ( <array> ). notice string literals in postresql written single quotes.


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -