SELECT * FROM 表 WHERE
date_format(date_,'%y-%m-%d') between date_format('${开始日期}','%y-%m-%d')
and date_format('${截止日期}','%y-%m-%d')
如何将上边的sql改写为 若开始日期和截止日期都为空,则显示所有数据
where 1=1
${if(len(time)==0,""," and date_format(date_,'%y-%m-%d') >= '"+time+"'")}
${if(len(time2)==0,""," and date_format(date_,'%y-%m-%d') <= '"+time2+"'")}
SELECT * FROM 表 WHERE 1=1
${if(len(开始时间)=0,"","and date_format(date_,'%y-%m-%d') between '"+开始时间+"' and '"+截止日期+"'")