我的表
id Type date
2 Expense 2017-09-07
3 Expense 2017-09-07
5 Expense 2017-09-06
6 Income 2017-09-06
2 Income 2017-09-07
3 Income 2017-09-07
5 Income 2017-09-05
6 Expense 2017-09-04
我在一个选择查询中需要此结果 费用和日期之间(2017-09-06和2017-09-07)
id Type date
2 Expense 2017-09-07
3 Expense 2017-09-07
5 Expense 2017-09-06
答案 0 :(得分:-1)
SELECT * FROM `table`
WHERE `Type`='Expense'
AND `date` BETWEEN '2017-09-06 00:00:00' AND '2017-09-07 00:00:00'
ORDER BY date ASC;
答案 1 :(得分:-1)
在查询结尾处只是一个简单的WHERE
子句,请查看HERE以便更好地理解。它是SQL
添加
WHERE Type = 'Expense'
AND date BETWEEN '2017-09-06' AND '2017-09-07'
FROM
SELECT
部分之后
答案 2 :(得分:-1)
很简单:
select * from yourtable t where t.type='Expense' and t.date BETWEEN '2009-06-25' AND '2009-07-01';
答案 3 :(得分:-1)
你可以使用它。
SELECT * FROM MyTable WHERE (Type = 'Expense') AND (date BETWEEN('2017-09-06' AND '2017-09-07')) ORDER BY date DESC