sql查询语句在数据库中可以正常执行,但是在mybatis中就不行了

cwkisasb 2018-10-10 09:24:33
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
...全文
2340 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

56,679

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧