我有数据库"目标"表即交易,账户,账户名称,金额
Date Account Account Name Amount
2015-01-05 000010 Cash on Hand 1,000.00
2015-01-05 000011 Check Item 5,000.00
2015-01-05 000012 Taxes 500.00
2015-01-05 000013 Bank Deposit 10,000.00
2015-01-05 000014 Loan Discount 100.00
2015-01-05 000015 Travel 20.00
2015-01-06 000010 Cash on Hand 3,500.00
2015-01-06 000011 Check Item 1,000.00
2015-01-06 000012 Taxes 100.00
2015-01-06 000013 Bank Deposit 20,000.00
2015-01-06 000014 Loan Discount 200.00
2015-01-06 000015 Travel 50.00
现在我的SQL是
Select * from aim where date = 20150106 or Account between
000012 and 000014
我想要这样的答案
2015-01-06 000010 Cash on Hand 3,500.00
2015-01-06 000012 Taxes 100.00
2015-01-06 000013 Bank Deposit 20,000.00
2015-01-06 000014 Loan Discount 200.00
我的查询会按日期和帐户进行过滤。我想包括"手头现金"在查询中,但它不属于BETWEEN子句。
答案 0 :(得分:0)
将其作为条件添加到where语句中:
Select * from aim where date = 20150106 and( Account between
000012 and 000014 or Account = `000010` )