select id from motel order by distance asc and then query by the id array.