Languages
[Edit]
EN

MySQL - select where IN values instead of using OR

3 points
Created by:
Keisha-Acosta
260

Quick solution

SELECT * FROM users WHERE user_id IN (1, 2, 3);

Above query uses where column_name IN (value1, value2, valueN) construction.

 

We can build the same query using OR:

SELECT * FROM users WHERE user_id = 1
OR user_id = 2
OR user_id = 3;

 

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join