in reply to DBI select IN Array
Perl does not execute Perl inside a Perl string. eg. print "1 + 1"; will output "1 + 1" and not "2". Set up your SQL string properly and it will be fine.
my @tagList = ('red', 'black'); my $sql = 'SELECT table FROM tags WHERE tag IN (' . join (', ', map {'?'} @tagList) . ')'; my $ID = $dbh->selectall_arrayref ($sql, undef, @tagList);
Update: Fix typo on last line s/taglist/tagList/; I never use camelCase in variable names so it was easy to miss :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: DBI select IN Array
by Tux (Canon) on Feb 20, 2019 at 15:07 UTC | |
|
Re^2: DBI select IN Array
by Anonymous Monk on Feb 20, 2019 at 09:42 UTC | |
by hippo (Archbishop) on Feb 20, 2019 at 10:02 UTC | |
by Anonymous Monk on Feb 20, 2019 at 11:55 UTC |