0

I have an array of ids such as:

a = [13, 51, 99, 143, 225, 235, 873]

What is the most efficient way of getting the records where the id is in the array.

I don't really want to use or such as WHERE id = 13 || 92 , as the array could be extremely long. I've tried this:

select * from authors where id <@ [11, 8, 51, 62, 7];

but that's not correct.

Thanks

1 Answer 1

1

Use any

select * 
from authors 
where id = any (array[11, 8, 51, 62, 7]);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.