mybatis的ifelse使用

https://blog.csdn.net/hcwbr123/article/details/79472660

 

现象:
mybatis的if else使用示例

方法:
1:mybatis 进行if else的判断使用
这里写图片描述
使用whern 和otherwise进行判断

代码:

    <select id="findDocumentByCid" parameterType="java.util.Map" resultMap="DocumentsMap">
        select * from v_documents where 1=1
         <choose>
        <when test="cid==null">
            and cid is null
        </when>
        <otherwise>
            and cid=#{cid}
        </otherwise>
        </choose>
         and ordicode=#{ordicode}
    </select>



<choose>
    <when test="">
        //...
    </when>
    <otherwise>
        //...
    </otherwise>
</choose>
posted @ 2020-08-28 12:00  kelelipeng  阅读(3112)  评论(0编辑  收藏  举报