[PLUG] Re: Perl DBI question

Randal L. Schwartz merlyn at stonehenge.com
Mon Feb 14 16:54:32 UTC 2005


>>>>> "Matt" == Matt Alexander <lowbassman at gmail.com> writes:

Matt> I'm trying to use the "?" DBI syntax with a like statement and
Matt> wildcards.  Here's what I want to do:

Matt> $sth = $dbh->prepare("select * from table where col1 like '%?%'");
Matt> $sth->execute($value);

"?" must be an entire value... so you need something like this:

$sth = $dbh->prepare("select * from table where col1 like ?");
$sth->execute("%$value%");

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!




More information about the PLUG mailing list