-----Original Message-----
>From: Beginner <[EMAIL PROTECTED]>
>Sent: Oct 31, 2007 9:20 PM
>To: beginners@perl.org, beginners@perl.org
>Subject: impatient DBI query
>
>Hi,
>
>I have ordered my Perl DBI book (is that a leopard?) but I am 
>impatient and want to know how I could do a select/like statement a 
>bit like this:
>
>SELECT foo FROM bar WHERE foo like 'baz%' 
>
>the % being the wildcard operator.
>

try something like this:

    my $dbh = DBI->connect(...);
    my $str = 'select foo from bar where foo like ?';
    my $sth = $dbh->prepare($str);
    $sth->execute('baz%') or die $dbh->errstr;
    my @results = $sth->fetchrow_array;
    $sth->finish;


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to