PDA

View Full Version : select from, query issue


bazz
01-31-2008, 04:27 PM
hi,

Difficult to explain... yet a simple issue.


my $var_to_match = 'A';

my $sth = $dbh->prepare("SELECT group_premises_business_id, group_name, premises_name, business_name
FROM $table
WHERE group_name = $var_to_match
")
or die "prepare statement failed: $DBI::errstr\n";


I need to match the first letter of the group_name, with the A of $var_to_match.

bazz

abduraooft
01-31-2008, 04:32 PM
$var_to_match = 'A%';
...WHERE group_name LIKE $var_to_match ?

bazz
02-01-2008, 02:44 PM
Doesn't seem to work.

Ahh, I found the probelm and it now does seem to work. Thank you :thumbsup:


here's the code so far, which will fill the array, if the path is found anywhere in the field values.


my $sth = $dbh->prepare("SELECT group_name
FROM $table
WHERE group_name LIKE '%${Path}%'
")
or die "prepare statement failed: $DBI::errstr\n";

$sth->execute;

while (my @fields = $sth->fetchrow_array) {
print qq( fields = @fields <br /> );
}

$sth->finish;




Instead of finding a match anywhere in the field value, I want only to match with the first character.

bazz