my $count = $dbh->selectrow_array('select count(*) from users where userid = ?', undef, $username); if ($count) { print "$username is valid\n"; }