While ile aldığın her id'yi temp bir tabloya at sonra temp tablonu select edersen istediğin sonucu elde edebilirsin.