lashX lashX - 2 years ago 51
SQL Question

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

I need to select multiple records

I use

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 Source
FROM `table`
where ID in (5263, 5625, 5628, 5621) 

is probably better, but not faster.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download