Fellow Monasterians,
This my be slightly OT for a PM SoPW question, but ... In my HTML I allow the user to click groups of 3 consecutive letters to narrow what will be displayed in a list.
HTML: <a href="../cgi-bin/listusers.pl?alpha=ABC">ABC</a> <a href="../cgi-bin/listusers.pl?alpha=DEF">DEF</a> etc....
My Perl attempts to set up the appropriate REGEXP in a MySQL SELECT statement to return only those lastnames beginning with those letters:
my $alpha = $query->param('alpha'); $alpha =~ /(\w)(\w)(\w)/; $stmt = "SELECT * FROM teamnew ORDER BY lastname WHERE lastname REGEXP + '^$1|^$2|^$3'";
But I keep getting an error that there is a syntax error in my SELECT statement. A print Dumper for $stmt shows:
which appears fine. What am I missing? TIA."SELECT * FROM teamnew ORDER BY lastname WHERE lastname REGEXP '^A|^B| +^C'"
20050204 Edit by castaway: Changed title from 'Setting up a MySQL REGEXP in Perl'
In reply to (OT) Setting up a MySQL REGEXP in Perl by bradcathey
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |