I've found posts of = vs IN for single value (link and link), but I'm asking actually for multiple values. Which is likely to perform better:
# Query 1:
SELECT * FROM tbl WHERE id = 50 OR id = 51 OR id = 52
# Query 2:
SELECT * FROM tbl WHERE id IN (50, 51, 52)
# Query 3:
SELECT * FROM tbl WHERE id >= 50 AND id <= 52
Note: id is primary and indexed, obviously.
WHERE id BETWEEN 50 AND 52
Q1
andQ2
are eqs.Q3
andQ by Lennart
are eqs. But this pairs of queries are NOT equivalent formally (for example, nothing in the text above preventid
to be floating-point number).IN
turns intoOR
, nor vice versa: See here