in reply to Simpler DBI::MySQL queries
The example below is ok because it asks for a single column and (assuming that the ids are unique, only a single row):
But this next example is bad, it retrieves all columns and while it *may* work, exactly which column is returned is not guaranteed:my $username = $dbh->selectrow_array(" SELECT username FROM tbl WHERE id = 9 ");
And this last example is only ok if you want the first row, but not the rest, since it may gather many rows and the selectrow_array will only return the first (note the less than comparison):my $username = $dbh->selectrow_array(" SELECT * FROM tbl WHERE id = 9 ");
my $username = $dbh->selectrow_array(" SELECT username FROM tbl WHERE id < 9 ");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Simpler DBI::MySQL queries
by Cody Pendant (Prior) on Dec 02, 2004 at 00:44 UTC | |
|
Re^2: Simpler DBI::MySQL queries
by Anonymous Monk on Dec 02, 2004 at 04:58 UTC |