in reply to DBI - I can't use bind variables with "like"?
Append and prepend % sign to each element.foreach my $word (@words) { my $sth = $dbh->prepare( "SELECT * FROM my_table WHERE description LIKE '?' OR shortdescription LIKE '?' OR name LIKE '?'" ) || die "Error: " . $dbh->errstr; #append and prepend percentage signs $word ="%".$word."%" ; $sth->execute($word,$word,$word) || die "Error: " . $dbh->errstr; # do some stuff }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: DBI - I can't use bind variables with "like"?
by clinton (Priest) on Jun 30, 2006 at 08:43 UTC |