SELECT * FROM Table WHERE id IN (1,2,3,4,5) AND ColB = (SELECT ColB FROM Table WHERE id IN (1,2,3,4,5) ORDER BY FIELD(id,1,2,3,4,5) LIMIT 1)