I'm sure this is a duplicate question in the sense that the answer is out there somewhere, but I haven't been able to find the answer after Googling for 10 minutes, so I'd appeal to the editors not to close it on the basis that it might well be useful for other people.
I'm using Postgres 9.5. This is my 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 to find all the rows with "Journal" in pub_types
.
I've found the docs and googled and this is what I've tried:
select * from mytable where ("Journal") IN pub_types;
select * from mytable where "Journal" IN pub_types;
select * from mytable where pub_types=ANY("Journal");
select * from mytable where pub_types IN ("Journal");
select * from mytable where where pub_types contains "Journal";
I've scanned the postgres array docs but can't see a simple example of how to run a query, and StackOverflow questions all seem to be based around more complicated examples.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…