sql查询语句在数据库中可以正常执行,但是在mybatis中就不行了
sql查询语句在数据库中可以正常执行,但是在mybatis中就不行了,因为mybatis在执行查询语句前会先执行count(0)的操作,同样的条件,查询*能查到,查询count却查不到,但是如果把1=1条件后面的条件删除了又能执行成功,是什么原理(该数据表不是我写的,这是一个varchar类型的 日期字段,里面有各种格式的日期)
注:该数据库管理系统是hana
sql语句如下:
select count(0) from (
select
cast(substring(replace(replace(replace(enddate,'-',''),'/',''),'.',''),1,4) as integer)*365 -- 截取年转换为天
+cast(substring(replace(replace(replace(enddate,'-',''),'/',''),'.',''),5,2) as integer)*30 -- 截取月转换为天
+cast(substring(replace(replace(replace(enddate,'-',''),'/',''),'.',''),7,2) as integer) -- 截取天
-(year(current_date)*365+dayofyear(current_date)) vday,* -- 当前日期的天数
from "HX_DATA"."TB_VENDOR_QM"
where length(replace(replace(replace(enddate,'-',''),'/',''),'.',''))=8
and (enddate like '%2%' or enddate like '%9%' or enddate like '%0%')
) where 1=1 and vday between 90 and 180