仅基于月份和年份选择mySQL [英] Select mySQL based only on month and year
本文介绍了仅基于月份和年份选择mySQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的mySQL DB中有一列,其中有一些行.此行之一是DATE,如下所示:2012-02-01
I have a column in my mySQL DB that has some rows. One of this row is a DATE, like this: 2012-02-01
我要实现的是仅基于年份和月份使用PHP进行SELECT.
What I want to achieve is to do a SELECT with PHP based only on the year and month.
SELECT的逻辑如下:
The logic of the SELECT will be the following:
$q="SELECT * FROM projects WHERE Date="SELECT HERE THE SPECIFIC YEAR AND MONTH"";
特定的月份和年份将从$_POST
变量传递,例如$_POST['period']="2012-02";
The specific month and year will be be passed from a $_POST
variable, like this $_POST['period']="2012-02";
我该怎么办?
推荐答案
SELECT * FROM projects WHERE YEAR(Date) = 2011 AND MONTH(Date) = 5
这篇关于仅基于月份和年份选择mySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文