Technically this works, but its really really bad to be making multiple round trips to the database like this. Why cant you just do a group by?