答案不能,chose when otherwise 相当与Java的 switch 多个 case 然后 default
<select id="findPageListByXmAndzjhm" resultMap="BaseResultMap">
select * from gg_xyryb g WHERE g.isdel='0'
<choose>
<when test="zjhm != null and zjhm != ''and ryxm != null and ryxm != ''">
and g.ryxm = #{ryxm,jdbcType=VARCHAR} OR g.zjhm = #{zjhm,jdbcType=VARCHAR}
</when>
<when test="ryxm != null and ryxm != ''">
and g.ryxm = #{ryxm,jdbcType=VARCHAR}
</when>
<otherwise>
AND g.zjhm = #{zjhm,jdbcType=VARCHAR}
</otherwise>
</choose>
</select>
SELECT * FROM (select g.*,l.ajbh ajbh,lb.rylb rylb,lb.rylx rylx from gg_xyryb as g LEFT JOIN gl_ragl as l on g.rybh = l.rybh LEFT JOIN gg_rylbb lb on g.rybh=lb.rybh where l.ajbh=#{ajbh,jdbcType=VARCHAR} and g.isdel=0 and l.isdel=0 <if test="rylb != null and rylb != ''"> and lb.rylb=#{rylb,jdbcType=VARCHAR} </if> <if test="rylx != null and rylx != ''"> and lb.rylx=#{rylx,jdbcType=VARCHAR} </if>) as sl RIGHT JOIN gl_jtrygl jt on sl.rybh=jt.rybh WHERE sl.rybh is NOT NULL