mybatis动态传入参数 pgsql 日期 Interval
在navicat中,标准写法
c
SELECT * FROM test
WHERE time > (NOW() - INTERVAL '5 day')
在mybatis中,错误写法
c
SELECT * FROM test
WHERE time > (NOW() - INTERVAL
#{numbers,jdbcType=INTEGER} ' day')
报错内容
c
Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near "$2"
位置:485
以上写法,相当于:
正确写法:
c
SELECT * FROM test
WHERE time > (NOW() - INTERVAL '1 day' *5)
mybatis:
c
SELECT * FROM test
WHERE
time > (NOW() - INTERVAL '1 day' *
#{numbers,jdbcType=INTEGER}