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;