my $sth = $dbh->prepare_cached("SELECT foo,bar from table where id = ?"); for my $id (@ids) { $sth->execute( $id ); my @results = $sth->fetchrow_array; $sth->finish; } #### my $placeholders = join ',', ('?') x @ids; my $sth = $dbh->prepare_cached( "SELECT id,foo,bar from table where id IN ($placeholders)", ); $sth->execute( @ids ); $sth->bind_columns( \my ($id, $foo, $bar ) ); while ( $sth->fetch ) { # Put values somewhere } $sth->finish;