in reply to Retrieving multiple records from database
Use the "IN" operator instead of "OR". Here's my favorite idiom (using placeholders):
my @ids_to_match = ( ... ); my $query = "SELECT somedata from table WHERE id IN (" . join(",", map {"?"} @ids_to_match ) .")"; my $sth = $dbh->prepare($query); $sth->execute(@ids_to_match);
Alternatively:
my $query = "SELECT somedata from table WHERE id IN (" . join(",", map { $dbh->quote($_) } @ids_to_match ) .")"; my $sth = $dbh->prepare($query); $sth->execute();
See DBI Recipes for more idioms.
_ _ _ _ (_|| | |(_|>< _|
In Section
Seekers of Perl Wisdom