my $sth = $dbh->prepare(q{SELECT user_id from user where user_id = ?}); $sth->execute( $user_name ); if( $sth->rows ) { # do something here } #### my ( $usr ) = $sth->fetchrow_array;