Mybatis如何通过不同条件插入不同数据

如题所述

案例: 非常简单

if条件里一般都是这样写的,你可以参考下:
delete from ***
<where>
<if test="null!=userId or null!=schoolId">
<if test="null!=userId"> and user_id = #{userId} </if>
<if test="null!=schoolId"> and school_id = #{schoolId} </if>
</if>
<if test="null==userId and null==schoolId">
1=0
</if>
</where>
温馨提示:答案为网友推荐,仅供参考
相似回答