in reply to Dynamic Query

tachyon has developed an excellent sample, and chromatic has pointed you in the direction of improving it.

Combining the two gives both simple and effective code. What you're looking for is an in clause in your SQL. It meshes very nicely with join in Perl:

my @company_ids = qw(10 15 20); # for example my $where = 'where company_id in (' . join(',', @company_ids) . ')'; # insert the where clause at the bottom of the sql $sql = END_SQL; select comp_name from companies $where END_SQL
I think it's a little clearer when it's all combined, but that's more a matter of taste:
$sql = <<END_OF_SQL; select comp_name from companies where company_id in ( @{[join(',', @company_ids)]} ) END_OF_SQL
HTH