首页 > 解决方案 > Mybatis String <= />= 字符串比较问题

问题描述

在 SQL 中:能够返回结果

SELECT * from result where 
(reportDate >= "2022-02-06" and reportDate <= "2022-02-13")

Mybatis中示例1:能够返回结果

SELECT * from result where 
(reportDate &gt;= "2022-02-06" and reportDate &lt;= "2022-02-13")

Mybatis example2中:无法返回结果。

SELECT * from result where 
(reportDate &gt;= #{startDate,jdbcType=VARCHAR} and reportDate &lt;= #{endDate,jdbcType=VARCHAR})

在 String 中 startDate 设置为“2022-02-06”,endDate 设置为“2022-02-13”。myBatis有没有办法比较String,或者我应该如何转换startDate和endDate?SQL 表中的 reportDate 也在 VARCHAR 中。

标签: spring-mybatismybatis-sql

解决方案


推荐阅读