Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the proper syntax for the Less Than/Equal operator in MyBatis 3?

Tags:

mybatis

How to use less than equal in MyBatis 3.

<select id="getLog" resultMap="BaseResultMap" parameterType="java.lang.String">
    SELECT * FROM(
        SELECT * FROM TABLE1
        WHERE COL1 =#{COL1,jdbcType=VARCHAR}
        ORDER BY DATE DESC
    ) TABLE2
    WHERE ROWNUM <= 20
</select>
like image 218
Nwel Avatar asked Aug 17 '15 04:08

Nwel


2 Answers

I show examples for the Greater Than/Equal Operator and the Less Than/Equal Operators:

ROWNUM &gt;= 20
ROWNUM &lt;= 20

Or, for readability, you can wrap them in CDATA

ROWNUM <![CDATA[ >= ]]> 20
ROWNUM <![CDATA[ <= ]]> 20
like image 126
Madness Avatar answered Oct 23 '22 15:10

Madness


Use CDATA to escape "<" similar like xml.

  <select id="getLog" resultMap="BaseResultMap" parameterType="java.lang.String">
    SELECT * FROM(
    SELECT * FROM TABLE1
    WHERE COL1 =#{COL1,jdbcType=VARCHAR}
    ORDER BY DATE DESC
) TABLE2
WHERE ROWNUM <![CDATA[ <= 20 ]]>
</select>
like image 23
Panther Avatar answered Oct 23 '22 15:10

Panther