in reply to how do i construct a sql select statement, where i want to get the where clauses out of an array

If there are not too many ids then you could do:
$where_clause = 'where id in ('.join(",",("?") x @id).')'; $sql .= $where_clause; my $sth = $dbh->prepare($sql); $sth->execute(@id);
If there ARE too many ids, then you're stuck with:
$sql .= 'where id = ?'; my $sth = $dbh->prepare($sql); for my $id (@id) { $sth->execute($id); ... }
How many is TOO many? Dunno. Depends. 256 or so?

Update: I like tilly's temp table idea. I've actually done that in some cases.

  • Comment on Re: how do i construct a sql select statement, where i want to get the where clauses out of an array
  • Select or Download Code