my $sth = $dbh->prepare(" SELECT COUNT(DISTINCT all_id) AS cnt FROM users "); $sth->execute(); my $count = $sth->fetchrow_hashref()->{cnt}; $sth->finish(); #### my $sth = $dbh->prepare(" SELECT COUNT(DISTINCT all_id) FROM users "); $sth->execute(); my $count = $sth->fetchrow_array(); $sth->finish(); #### my $count = $dbh->selectrow_array(" SELECT COUNT(DISTINCT all_id) FROM users ");