错误信息:
the error coming as 'SQL state 42725: ERROR: function to_char(unknown, unknown) is not unique'
<select id="getbYtime" resultMap="map">
select * from book where to_char(create_time, 'YYYY-MM-DD') between to_char(#{stateDate} , 'YYYY-mm-dd') and to_char(#{endDate}, 'YYYY-mm-dd')
</select>
我的startDate和endDate都是传入的Date类型。但是这样时报错的需要指定这两个参数的具体类型:
<select id="getbYtime" resultMap="map">
select * from book where to_char(create_time, 'YYYY-MM-DD') between to_char(#{stateDate}::date , 'YYYY-mm-dd') and to_char(#{endDate}::date, 'YYYY-mm-dd')
</select>
或者:
<select id="getbYtime" resultMap="map">
select * from book where to_char(create_time, 'YYYY-MM-DD') between to_char(#{stateDate}::timestamp, 'YYYY-mm-dd') and to_char(#{endDate}::timestamp, 'YYYY-mm-dd')
</select>