-4

我想从特定日期的 sql 中检索日期,如果特定日期的数据不可用,我想显示消息。

4

2 回答 2

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";
}
于 2012-10-11T07:18:41.353 回答
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
于 2012-10-11T07:14:27.137 回答