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 need to select few rows in 1 query by it's ID , for example here is something that i wrote
SELECT * FROM posts WHERE post_id = "15 , 14 , 14"
how can it be done in real sql query?
SELECT * FROM posts WHERE post_id IN (14,15);
Add a comment
SELECT * FROM posts WHERE post_id IN ( "15" , "14" )
The fastest option and is more efficient:
SELECT * FROM posts WHERE post_id IN (14,15)
However using instructions OR is not wrong
OR
SELECT * FROM posts WHERE post_id = 14 OR post_id = 15
Use OR / AND in where condition. Like:
SELECT * FROM posts WHERE post_id = '13' OR post_id = '14' OR post_id = '15'
You could also use:
SELECT * FROM posts WHERE post_id BETWEEN 14 and 15
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.