2

I have an database like this.

vendors
id    title        
1    'Papa Johns'
2    'Google'

I have an starred array that could look like this: [1] or [1, 2]

I want to write a query which selects everything in the starred array, this is what I tried:

SELECT * FROM vendors WHERE vendors.id IN [1, 2]

But that gave a syntax error, I'm not sure of the correct syntax?

1 Answer 1

2

If you want to use integer constans, use IN:

SELECT * 
FROM vendors 
WHERE vendors.id IN (1, 2);

Alternatively, you can use ANY(array):

SELECT * 
FROM vendors 
WHERE vendors.id = ANY(array[1, 2]);
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.