我在Oracle中用MyBatis Mapper xml文件编写了查询,如下所示:
<select id="getUserList" resultMap="userListResult" parameterType="org.user.UserNumber>
select * from user
WHERE (1=1)
<if test="num != null">AND rownum <= #{num}</if>
</select>
我需要遵守Postgres标准。所以,转换如下:
<select id="getUserList" resultMap="userListResult" parameterType="org.user.UserNumber>
select * from user
WHERE (1=1)
<if test="num != null">AND LIMIT #{num}</if>
</select>
但它不起作用并抛出异常: PSQLException:错误:语法错误位于或附近\&#34; LIMIT \&#34; \ n
有人可以帮我解释如何在Postgres中替换rownum吗?