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

mysql supports the IN() clause. So it might be easiest to use this:

SELECT id, size FROM table WHERE id IN ('$id[0]', '$id[1]', ...)

Which i would build this way, but there are plenty of others:

my $idlist = join(',', map($dbh->quote($_),@id)); $statement = "SELECT id, size FROM table WHERE id IN ($idlist)";

Apparently there are issues with the length of @id: past a certain point it would need to be divided into chunks for this approach to work.

update *sigh*. redundant again.

  • 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