in reply to Passing a value into a WHERE clause
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); ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Passing a value into a WHERE clause
by peppiv (Curate) on Jan 28, 2002 at 18:58 UTC |