UPDATE users
SET membership_status = 'ACTIVE'
FROM organization_members
WHERE users.id = organization_members.user_id
  AND users.membership_status = 'PENDING'
  AND organization_members.status = 'ACTIVE';