I spent 15 minutes trying to get this into a single query and then said screw it, we'll just loop :)