[英]Simple perl mysql query not working
我已经离开了mysql和perl游戏已有好几年了,似乎无法做到这一点。 我有一个只有3列的表。 'cnt'就是其中之一。 我想做的就是在'name'上查询表,看看是否存在名称。 如果是,我想捕获'cnt'的值。 该表有一个testName记录,值为2我手动添加。 运行此脚本时,它返回空。
my $count;
my $pop = qq(SELECT cnt FROM popular WHERE name="testName");
my $sth = $dbh->prepare($pop);
$sth->execute() or die $dbh->errstr;
my @return;
while (@return = $sth->fetchrow_array()) {
$count = $return[1];
}
print "our return count is $count";
任何人都明白我做错了吗?
你可能意味着
$count = $return[0];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.