获取最近一个月的记录

时间:2014-08-29 22:24:02

标签: mysql

我有一个存储标题和出版物(DATE格式)的简单表格,需要获取最近一个月/年的所有记录。

select title, pub_date FROM news ORDER BY pub_date DESC

1 个答案:

答案 0 :(得分:-1)

SELECT title, pub_date 
FROM news 
WHERE MONTH(pub_date) = (SELECT MONTH(MAX(pub_date)) FROM news ORDER BY pub_date DESC LIMIT 1)
ORDER BY pub_date DESC