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}'
asked Jun 19, 2020 at 15:58

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}'
answered Jun 19, 2020 at 18:30

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.