Sign up ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free.

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 and id=2 and id=3

Should I loop through every id and perform a query for each iteration?

share|improve this question

2 Answers 2

up vote 1 down vote accepted
select *
from table
where id in (1, 2, 3)
share|improve this answer

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.

You actually want results where id = 1 or id = 2 or id = 3

Or you want results where id in (1, 2, 3)

Or you want results where id between 1 and 3

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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