Re: print records that match regexp
- From: chas.owens@xxxxxxxxx (Chas. Owens)
- Date: Tue, 29 Jan 2008 08:55:38 -0500
On Jan 29, 2008 2:03 AM, <bbrecht56@xxxxxxxxx> wrote:
snip
Sorry, I missed the "^" for the regexp ^A+snip
The ^ should only be used if you were to use Perl regexes, and even
then your expression would not match anything but strings that held
"A"s (+ matches the last character 1 or more times). But you should
not be using Perl regexes, you should be using the SQL operator LIKE
and its pattern matching language.
snip
I applied your method but the query does not return any record fromsnip
the table.
Also when I try to match only one field using like:
my $arg = shift;
my $sth = $dbh->prepare (" SELECT * FROM $tableName firstname like
'$arg' ");
$sth->execute();
This sure doesn't look like my code. Try this hard code first and the
work your way up to doing it dynamically:
my $sth = $dbh->prepare("SELECT * from $tableName where firstname like
'A%' or lastname like 'A%' or email like 'A%'");
Also, you should read up on SQL injection attacks:
http://en.wikipedia.org/wiki/Sql_injection
.
- Follow-Ups:
- Re: print records that match regexp
- From: bbrecht56
- Re: print records that match regexp
- References:
- print records that match regexp
- From: bbrecht56
- Re: print records that match regexp
- From: Chas. Owens
- Re: print records that match regexp
- From: bbrecht56
- print records that match regexp
- Prev by Date: Re: How to match a token not be quoted?
- Next by Date: Re: How to avoid this greedy match?
- Previous by thread: Re: print records that match regexp
- Next by thread: Re: print records that match regexp
- Index(es):