I have an array in SQL like
CREATE TABLE Table1 (
examples text ARRAY);
INSERT INTO Table1
(examples)
VALUES
{t1,t2,t3};
I can’t find a description of the correct syntax to do select * from Table1 where (values) in (anysome)
examples
I tried the tutorial example but it doesn’t work or I just don’t understand something
select *
from player_scores
where 95 < any (round_scores);
Do I understand correctly that you need to do something like this –
Postgresql Select rows where column = array
or this –
How to check if any field of array not contains substring in Postgres?
SELECT * FROM Table1 WHERE "value" = any (examples);
2
Answers
DB fiddle
Your query should be:
You can check this answer too.
Yes, it is correct. if you want to check whether a value is in a PostgreSQL array, you can use function
ANY()
.ANY()
returns true if the value is present in the array, and false otherwise.Furthermore you need to use single quotes instead of double quotes when using
ANY()
with arrays in PostgreSQL. The reason isANY()
expects the array elements to be enclosed in single` quotes: