Reputation: 335
I've got an issue, I am trying to collect a number of defined emails from a database, I collect them via the ID of each client.
Therefore, I currently have 1000 users in the database and I only want the emails from IDs 10, 11, 23, 34, 56, 33, 340, 433, 434, etc...
Besides the "
SELECT email FROM users WHERE id=10 OR id=11 OR id=23 OR id=34...
etc" is there any other method that I could includes all the IDs simultaneously without having to write an OR condition each time and ID is added?
Thank you.
Upvotes: 0
Views: 63
Reputation: 80639
SELECT email FROM users WHERE id IN (10, 11, 23, 34, 56, 33, 340, 433, 434);
Upvotes: 1
Reputation: 263723
Use IN
SELECT email
FROM users
WHERE ID IN (34, 56, 33, 340, 433, 434)
Upvotes: 2