my $sth = $dbh->prepare(" SELECT COUNT(DISTINCT all_id) FROM users "); $sth->execute(); my $count = $sth->fetchrow_array(); $sth->finish();