[英]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.