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