prepare('SELECT DISTINCT award_sponsors_id FROM award_contacts'); $q->execute(); while ($i = $q->fetch(PDO::FETCH_OBJ)) { $asid = $i->award_sponsors_id; $stmt = $pdo->prepare("UPDATE award_contacts SET `primary`='yes' WHERE award_sponsors_id=? LIMIT 1"); $stmt->execute([$asid]); } } ?>