note
mje
<p>Something like (untested):</p>
<code>
my @query_ids = (5,4,3,2,1);
my $sql = q/select rec_data from foo where id in (/ . join(",", @query_ids) . q/) order by id/;
my $results = $dbh->selectall_arrayref($sql);
</code>
<p>You can also use placeholders which most people will say are better (which they are) but it depends on how big @query_ids is. Some database engines have quite low limits on the number of parameters. Anyway, to do it that way:</p>
<code>
my @query_ids = (5,4,3,2,1);
my $sql = q/select rec_data from foo where id in (/ . join ",", ("?") x @query_ids .q/) order by id/; print $sql;'
select rec_data from foo where id in (?????) order by id
my $results = $dbh->selectall_arrayref($sql, undef, @query_ids);
</code>
<p>Are you also asking to get the rows back in the order they are in @query_ids?</p>
1081791
1081791