... $sth = $dbh->prepare("select count(distinct all_id) from users") or die ("Error in SQL\n"); $sth->execute(); my $counts = $sth->fetchrow_hashref(); print "There are $counts in this table"; ...