0

Rough table structure:

id                      uuid
fields                  jsonb
created_at              timestamptz
related_content_ids     _uuid
updated_at              timestamptz

I'm trying to write a query that will find all records in this table that have at least one value from a specified array in the related_content_ids column.

Something like this works for matching all values in the array, but I just need at least one to match:

SELECT * FROM content WHERE related_content_ids @> '{fbaa1235-1069-496f-9a54-e91e13aadae8,65a109eb-ee4b-4a23-9f91-6980b5bb9340}'

1 Answer 1

2

"At least one match" can be done using the "overlaps" operator &&

select *
from content
where related_content_ids && '{fbaa1235-1069-496f-9a54-e91e13aadae8,65a109eb-ee4b-4a23-9f91-6980b5bb9340}'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.