本文介绍了选择从一年前到现在的所有记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个充满很多行的表,我需要选择到目前为止不到一年的所有行.
I have a table filled with a lot of rows and I need to select all the rows that are less than a year old till now.
表(称为orders
)具有名为order_date
的DateTime
列,该列确定下订单的时间.
The table (called orders
) has a DateTime
column named order_date
, that's the field that determines when the order was placed.
如何选择从现在到一年前的所有具有order_date
的记录?
How can I select all the records that have an order_date
between now and a full year ago?
推荐答案
select *
from orders
where order_date >= DATE_SUB(NOW(),INTERVAL 1 YEAR);
这篇关于选择从一年前到现在的所有记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!