SQL BETWEEN QUERY

时间:2016-02-16 18:45:22

标签: mysql

民间,

需要帮助,我有这个查询在最后12个mnonths之间返回teamA的所有数据。但我无法正确显示数据。

SELECT * 
FROM table 
WHERE team= 'teamA' BETWEEN ('2015-12-31') AND (DATE_SUB('2015-12-01',INTERVAL 12 MONTH)) 
ORDER BY date ASC;
你可以帮帮我吗?

PD:我的英语非常糟糕;(

1 个答案:

答案 0 :(得分:0)

试试这个

SELECT * 
FROM table 
WHERE team= 'teamA' AND time BETWEEN ('2015-12-31') AND (DATE_SUB('2015-12-01',INTERVAL 12 MONTH)) 
ORDER BY date ASC;

其中时间是日期栏