in reply to Dynamic Query
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:
I think it's a little clearer when it's all combined, but that's more a matter of taste: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
HTH$sql = <<END_OF_SQL; select comp_name from companies where company_id in ( @{[join(',', @company_ids)]} ) END_OF_SQL
|
|---|