簡體   English   中英

檢查結果為空mysql

[英]check result null mysql

這下面的mysql命令返回空結果。

如何在PHP中檢查

SELECT (sum(`money1`) - sum(`money2`)) as sm FROM `manfeatokasb`

以下代碼不正確,無法檢查空結果

if ($result['sm'] === null  )
{
    echo 'this command is return null result';
}

使用is_null()

if (is_null($result['sm']))
{
    echo 'this command is return null result';
}

您可以使用mysql_num_rows

if(mysql_num_rows($result) != 0){
     //code if "not null"
}else{
    //code if "null"
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM