in reply to DBI - I can't use bind variables with "like"?
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; $sth->execute($word,$word,$word) || die "Error: " . $dbh->errstr; # do some stuff }
# Add percent sign for LIKE value in DB Search $word .= "\%$word\%";
my $sth = $dbh->prepare( "SELECT * FROM my_table WHERE description LIKE ? OR shortdescription LIKE ? OR name LIKE ?" ) || die "Error: " . $dbh->errstr;
|
|---|