从特定日期的sql检索数据&显示消息

时间:2012-10-11 07:11:20

标签: php sql

我想从特定日期的sql中检索日期,并希望在特定日期的数据不可用时显示消息。

2 个答案:

答案 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