sql查询以获取未来30天的记录 [英] sql query to fetch the records of next 30 days
本文介绍了sql查询以获取未来30天的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的问题,我想从表中获取未来30天的记录.我的桌子上有一个字段.例如:在我的表中有resource_date
,在此列中有许多记录,从2013-02-05
到2015-10-10
.假设,如果我今天登录该网站(今天的日期是-16/01/2015
,它应该获取接下来15天的记录,依此类推).这该怎么做?预先感谢
Here is my problem, I want to fetch next 30 days records from the table. I have a field in my table. For ex: In my table I have resource_date
, In this column I have many records from 2013-02-05
to 2015-10-10
. Say, If I logged into the website today(Today's Date is- 16/01/2015
, It should fetch record for next 15 days and so on). How to do this? Thanks in advance
推荐答案
一种方法
SELECT *
FROM table1
WHERE resource_date >= CURDATE() + INTERVAL 1 DAY -- skip today
AND resource_date < CURDATE() + INTERVAL 17 DAY -- 15 days starting tomorrow
这是一个 SQLFiddle 演示
Here is a SQLFiddle demo
这篇关于sql查询以获取未来30天的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文