我想从特定日期的sql中检索日期,并希望在特定日期的数据不可用时显示消息。
答案 0 :(得分:7)
$result = mysql_query("SELECT * FROM yourTable WHERE date = 'dateYouWantToCheck'");
$num_rows = mysql_num_rows($result); //count number of rows returned
if($num_rows > 0)
{
//Show details here
}
else
{
echo "No match found";
}
答案 1 :(得分:2)
伪代码
SELECT CASE WHEN LENGTH(X.DATA) > 0 THEN X.DATA ELSE 'No Data Found' END
FROM
(SELECT DATA FROM <TABLE NAME> WHERE DATE = <SOME DATE> )X