"Christopher J. Crane" wrote:
> 
> Below is a snippet of my code with your suggestion on using CLIKE. The
> problem is that now this SQL statement:
> "SELECT ProductLineName,PartNumber FROM SiliconBridgeRectifers WHERE
> ProductLineName CLIKE '$form{'ProductLine'}%'"
> 
> returns everything in the database. Am I doing something wrong here? In
> fact, even if $form{'ProductLine'} is NULL it returns everything in the
> database.

If $form{'ProductLine'} is undefined then the value for the CLIKE operator
becomes '%' which matches everything.

For debugging purposes, I recommend you print out the SQL statement executing
it:

$sql = "SELECT ProductLineName,PartNumber FROM SiliconBridgeRectifers WHERE
ProductLineName CLIKE '$form{'ProductLine'}%'");
$sth = $dbh->prepare($sql);
print STDERR "About to execute the following statement:\n$sql\n";

--
  Simon Oliver

Reply via email to