in reply to Perl Mysql Null Recordset

I am using DBI with MySQL and am looking for a way to test if a query returned an empty recordset.

You might have better luck by rephrasing the question as "how many users with this name exist?"

Try something like this (untested):

my $sth = $db1->prepare( "SELECT count(*) FROM users WHERE username = ?" ); $sth->execute($Username_POST); my $rs = $sth->fetchall_arrayref(); my $count = $rs->[0]->[0];

Replies are listed 'Best First'.
Re^2: Perl Mysql Null Recordset
by JoeJaz (Monk) on Nov 16, 2004 at 22:08 UTC
    I have never seen that syntax before. It is very sisinct; I like it. Thanks for providing your code. Joe