mybatis的ifelse使用

现象:
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>

猜你喜欢

转载自blog.csdn.net/hcwbr123/article/details/79472660