mysql:使用PHP选择特定月份的所有条目 [英] mysql: select all entries from a particular month using PHP
本文介绍了mysql:使用PHP选择特定月份的所有条目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个名为POST
的mysql数据库表.
字段之一是时间戳记,在创建记录时将其默认设置为mysql服务器上的当前时间戳记.
I have a mysql database table called POST
.
One of the fields is a timestamp, set to default to the current timestamp on the mysql server when the record is created.
我需要一个SQL查询来提取特定月份内所有带有时间戳的行.也就是说,3月的所有记录或11月的所有记录,等等.
I need a SQL query to extract all rows that have a timestamp within a particular month. That is, all records for March, or all records for November, etc.
推荐答案
您必须使用或month(),但此函数将返回一个数字
or month(), but this function will return a number
select * from thetable where month(date_field) = 2
这篇关于mysql:使用PHP选择特定月份的所有条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文