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

后端 未结 5 1209
南方客
南方客 2021-02-03 23:37

I need to select multiple records

I use

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

this

5条回答
  •  时光取名叫无心
    2021-02-04 00:03

    SELECT *
    FROM `table`
    WHERE `ID` IN (5623, 5625, 5628, 5621)
    

    But four times per second is a lot. I would think about another approach that needs less database access.

提交回复
热议问题