in reply to Re: select from mysql table based on two column match
in thread select from mysql table based on two column match

Hi madtoperl,

Your code contains “smart” quotes, so it won't compile.

$dbh->prepare('SELECT * FROM charge WHERE column1 = $cptcode AND column2 = $cpt2code’)

Single quotes won't interpolate these variables, and even if they did, you shouldn't ever interpolate user input into SQL! Use placeholders instead.

my $cptcode = <STDIN>;

These values need to be chomped to remove the trailing newline.

Update: Looks like marto and I had almost the same thoughts at the same time :-)

Regards,
-- Hauke D

  • Comment on Re^2: select from mysql table based on two column match