write a single SQL call to get this rather than hitting the DB twice.