我有一个存储标题和出版物(DATE格式)的简单表格,需要获取最近一个月/年的所有记录。
select title, pub_date FROM news ORDER BY pub_date DESC
答案 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