Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I am trying to figure out how I can select multiple rows from a table, based on the id column. Something like this:
select * from table where id=1 or id=2 or id=3
Should I loop through every id and perform a query for each iteration?
select * from table where id in (1, 2, 3)
Add a comment
If you want to have results where id = 1 and results where id = 2 and results where id = 3, you have to use a different logic.
id = 1
id = 2
id = 3
You actually want results where id = 1 or id = 2 or id = 3
id = 1 or id = 2 or id = 3
Or you want results where id in (1, 2, 3)
id in (1, 2, 3)
Or you want results where id between 1 and 3
id between 1 and 3
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.
Explore related questions
See similar questions with these tags.