Mysql之间的查询无法正常工作

Adi*_*ote 1 mysql date between

我正在使用mysql.我想在两个日期之间显示记录.我在网上搜索,发现mysql的日期格式是yyyy/mm/dd.所以我写的查询如下,

select 
    * 
from tbl_reservation 
where 
    current_date between '2014-03-28' and '2014-03-26';
Run Code Online (Sandbox Code Playgroud)

但是,我不知道它为什么不起作用."col_date"具有DATE数据类型.我不是在里面存放时间.

让我告诉你我在后端做了些什么,

SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
Date curr_date=new Date();
String compareDate=sdf.format(curr_date);
Run Code Online (Sandbox Code Playgroud)

我将此值存储在"col_date"中.它是否因为这种处理而发生?

感谢您提前宝贵的时间.

Rav*_*ddy 7

使用BETWEEN,首先使用最少日期,然后使用最新日期

它应该是:

select * from tbl_reservation 
where col_date between '2014-03-26'  -- least date
                   and '2014-03-28'; -- latest date
Run Code Online (Sandbox Code Playgroud)