Thanks Tom, I tried your suggestion but no luck. Still no results. I'm running 4.0.23 of MySQL and 8.4+ of ActiveState. I wonder if this is a bug in DBI?
Siegfried -----Original Message----- From: Tom Allison [mailto:[EMAIL PROTECTED] Sent: Thursday, July 21, 2005 8:08 PM To: Siegfried Heintze Subject: Re: How to use % in MySQL SQL statement from Perl? Siegfried Heintze wrote: > The following code works with perl/MySQL. If I comment the second line, > however, it does not work. No error messages and no results. > > If I use the MySQL Enterprise console and type in my first SELECT statement > that includes the LIKE clause, it works. > > I'm stumped. There must be something strange with that "%", but I cannot > figure it out. > Anyone got any suggestions? > > Siegfried > > my $sJobTitle = q[SELECT sName FROM keywords ORDER BY sName WHERE sName LIKE > '%']; > $sJobTitle = q[SELECT sName FROM keywords ORDER BY sName]; > > my $sth = DBH->prepare($sJobTitle); > $sth->execute(); > my $row; > while ($row = $sth->fetch){ > push @sResult,"<li>".join( "", @$row)."</li>\n"; > } > > escape ' ? I don't use the q[ ] approach much since SQL servers tend to be unsophisticated. my $sJobTitle = "SELECT sName FROM keywords ORDER BY sNaem where sName LIKE '%'"; should work. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>