[英]MySQL range date from first date result to x days
Sorry if the question title is a little vague, I'm not sure the best way of wording it. 抱歉,如果问题标题含糊不清,我不确定最好的措辞方式。
The columns in my query are id and date_added 我查询中的列是id和date_added
I am wanting to get results from my table and I have a "date range". 我想从表中获取结果,并且有一个“日期范围”。
Lets say the day range is 5 So if the first row had the date "2013-04-01" then it will show all results from "2012-04-01" up to the "2012-04-06". 假设日期范围是5,因此,如果第一行的日期为“ 2013-04-01”,则它将显示从“ 2012-04-01”到“ 2012-04-06”的所有结果。 The problem is that first date changes regularly.
问题在于初次约会会定期更改。
This is my query right now, but it isn't working correctly 这是我目前的查询,但无法正常工作
SELECT oh.date_added AS date_shipped, o.date_added FROM oc_order o , oc_order_history oh WHERE o.order_id = oh.order_id AND oh.order_status_id = 3 AND oh.date_added BETWEEN oh.date_added AND DATE_ADD(oh.date_added, INTERVAL 1 DAY)
I hope this makes sense. 我希望这是有道理的。
Thanks, Peter 谢谢彼得
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.