欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Mybatis 大于小于、大于等于、小于等于等转移字符书写

程序员文章站 2024-02-24 13:44:46
...

 

第一种写法:

原符号 < <= > >= & ' "
替换符号 &lt; &lt;= &gt; &gt;= &amp; &apos; &quot;

SQL示例如下:

 select * from (
            select * from (<include refid="baseOrderInfoVo" />) a
            union all
            select * from (<include refid="baseOrderReturnVo" />) b
            union all
            select * from (<include refid="baseSpjhdVo" />) c
        ) billdtovo
        <where>
            <if test="term.q!=null and term.q!='' "> and djbh like concat('%',#{term.q},'%') </if>
            <if test="term.djlx!=null and term.djlx!='' ">and  djlx=#{term.djlx} </if>
            <if test="term.state!=null  ">and  status=#{term.state} </if>
            <if test="term.rqf!=null and term.rqf!='' "> and rq &gt;= #{term.rqf} </if>
            <if test="term.rqt!=null and term.rqt!='' "> and rq &lt;= #{term.rqt} </if>
        </where>
        order by djlx,rq,djbh

第二种写法:

大于等于 <![CDATA[ >= ]]>
小于等于 <![CDATA[ <= ]]>

SQL示例如下:

   select * from (
            select * from (<include refid="baseOrderInfoVo" />) a
            union all
            select * from (<include refid="baseOrderReturnVo" />) b
            union all
            select * from (<include refid="baseSpjhdVo" />) c
        ) billdtovo
        <where>
            <if test="term.q!=null and term.q!='' "> and djbh like concat('%',#{term.q},'%') </if>
            <if test="term.djlx!=null and term.djlx!='' ">and  djlx=#{term.djlx} </if>
            <if test="term.state!=null  ">and  status=#{term.state} </if>
            <if test="term.rqf!=null and term.rqf!='' "> and rq <![CDATA[ >= ]]> #{term.rqf} </if>
            <if test="term.rqt!=null and term.rqt!='' "> and rq <![CDATA[ <= ]]> #{term.rqt} </if>
        </where>
        order by djlx,rq,djbh
相关标签: Java后端