If you do
SELECT *
FROM `table`
WHERE `ID` IN (5623, 5625, 5628, 5621)
You should be fine, as long as the number of ID's don't get too big. I'd suggest you create an index for the ID's, so the query will perform faster.
Also, consider changing your logic, so you don't have to pass that many ID's