Your example very nearly gets you there. The trick is to supply the field name before the DBMS sees the query. Easy enough to do. All you need is Perl's standard variable interpolation. Try something like:
my $field = 'answer'; my $value = 42; my $str = dbh->prepare("SELECT * FROM t WHERE $field = ?"); $sth->execute($value); ...
In reply to Re: Passing a value into a WHERE clause
by dws
in thread Passing a value into a WHERE clause
by peppiv
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |