lashX lashX - 6 months ago 7
SQL Question

What is the best way to select multiple rows by ID in sql?

I need to select multiple records

I use

SELECT *
FROM `table`
WHERE `ID` =5623
OR `ID` =5625
OR `ID` =5628
OR `ID` =5621


this query run 4 times in every second whit php

is there a better and faster way for this ?

Answer
SELECT *
FROM `table`
where ID in (5263, 5625, 5628, 5621) 

is probably better, but not faster.