in reply to sql select with array

Please enclose your code in code-tags, read the help pages about that.

Now to your problem:

You have to join your column names like this:

my $row = $dbh->selectall_arrayref('select ' . join(',', @selector) . " from people where (fornavn like '%$search%') or (efternavn like '%$s +earch%') or (cpr LIKE '%$search%')",\ %attr);

Replies are listed 'Best First'.
Re: sql select with array
by Ranna (Acolyte) on Oct 23, 2001 at 07:41 UTC
    Or, if you're not stuck on using just $dbh->selectall_arrayref and your database supports placeholders, couldn' you do this?
    $sth = $dbh->prepare("SELECT " . '? ' x $#selector . "FROM people WHER +E (fornavn LIKE '%$search%') or (eternavn LIKE '%$search%') or (cpr L +IKE '%$search%'", \%attr); #dunno if you can do the \%attr part... $sth->execute(@selector);
    And then you've got a statement handle to get your data from.. I don't know if it's more efficient, but it seems a bit more readable to me.
      No, you can't. Placeholders are allowed in where clauses and as update values only.

      Well, _some_ DBD's support them in the way you'd use them, but I wouldn't rely on that.