View Full Version : Retrieving from table where first letter matches a given
hi,
Folowing on from ealrier, here is my code
my $sth = $dbh->prepare("SELECT Business_Group_Name From $table
WHERE Business_Group_Name LIKE 'b%' ");
I need to do something like
WHERE Business_Group_Name LIKE '$Path%' ");
but it won't work presumably because of the single ' '. I have tried double quoutes without success.
Any ideas please?
bazz
blimey, I think I fluked it :D
my $sth = $dbh->prepare("SELECT Business_Group_Name From $table
WHERE Business_Group_Name LIKE \"$Path%\" ");
$sth->execute;
the old escape char worked. But is the correct way?
bazz
nkrgupta
08-20-2007, 08:54 PM
It is a correct way, but definitely not the neatest. You might want to have a look @ http://search.cpan.org/~timb/DBI-1.58/DBI.pm#quote
Naveen
nkrgupta
08-20-2007, 09:02 PM
On a different note, using Placeholders in DBI programming can greatly increase the efficiency of your programs.
http://www.perlmonks.org/?node_id=7548
Naveen
Thanks Naveen.
I'll read up on those tomorrow. I have made enough progress today to take a break overnight (I think). :)
bazz
FishMonger
08-20-2007, 10:04 PM
Did you enable RaiseError and/or PrintError? If so, what was the error?
Have you tried:
WHERE Business_Group_Name LIKE '${Path}%' ");
Great you guys. works a treat :thumbsup:
@Naveen, I don't yet fully understand all that at cpan. But I'll keep going over it in the next few days.
bazz
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.