[英]Mysql Query Not Giving Output
Iam newbie to Php and mysql.I have a datetime field in database and upon that datetime field iam generating a report.Here is my query 我是Php和mysql的新手,我在数据库中有一个datetime字段,并根据该datetime字段iam生成报告。这是我的查询
$date = $year."-".$month;
SELECT *FROM table WHERE request_date LIKE '$date%';
The month and year variables iam taking from input fields in a form.Here iam concatinating those two variables and passing them in the query.But it retruns nothing. 我将月份和年份变量从表单的输入字段中提取出来,在这里我将这两个变量隐藏起来并在查询中传递它们,但它不会重新运行。 The stored value in request_date is of formate 2011-02-28.
request_date中的存储值的格式为2011-02-28。
Kindly help how to do this. 请帮助如何执行此操作。
regards; 问候;
If you need to query for Year and month field then you could do: 如果您需要查询年和月字段,则可以执行以下操作:
SELECT * FROM projects
WHERE YEAR(request_date) = $year AND MONTH(request_date) = $month
put space between *
and FROM
like this. 像这样在
*
和FROM
之间放置空格。
$date = $year."-".$month;
SELECT * FROM table WHERE request_date LIKE '$date%';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.