I have a postres table that looks like such: (shortened)
id (serial) | col1 (character varying[])
----------------------------------------
1           | {'Life', 'Health', "'VA Data'"}
I am trying to do the following:
SELECT * FROM mytable WHERE 'Life' = ANY (col1)
The results of this query, is zero records.
The goal being, I want any row, that has the value 'Life' within the col1 array.
What am I doing wrong?
Any should work, but what you are showing me for output for the table is not Life but 'Life'. See the examples below (1. correctly inserted data and what it looks like; 2. incorrectly inserted data and what it looks like-looks like yours; 3. all data):
testdb=# select * from test where 'Life' = ANY(col1);
 id |          col1           
----+-------------------------
  1 | {Life,Health,"VA Data"}
(1 row)
testdb=# select * from test where '''Life''' = ANY(col1);
 id |           col1            
----+---------------------------
  2 | {'Life',Health,"VA Data"}
(1 row)
testdb=# select * from test;
 id |           col1            
----+---------------------------
  1 | {Life,Health,"VA Data"}
  2 | {'Life',Health,"VA Data"}
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