Got a little problem in my code, the query works fine if I manually put values in. But failed if I use my variable. The code shows below
my $get_meter_id = $dbh->prepare("SELECT * from t_readings where meter_serial = '21001652' AND ...");
$get_meter_id->execute() or die "Couldn't execute statement: ".$get_meter_id->errstr;
my $meter_reg_id = $get_meter_id->fetchrow_array();
Above one works
where meter_serial = 21001652 AND ...")
Above one works.
where meter_serial = '".$variable."' AND ...")
Above doesn't work
where meter_serial = ".$variable." AND ...")
Above doesn't work
Many thanks.