mybatis中if test 语句 当参数类型为string时,如何写判断条件


代码片段:
<select id="findPhonesById" parameterType="java.lang.String" resultType="java.lang.String">
select phone from contact_list cl left join contact_group cg on cl.d_id = cg.id
where 1 = 1
<if test="_parameter == 1">
and cl.d_id in (select distinct d_id from contact_list)
</if>
<if test="_parameter != 1">
and cl.d_id = #{id}
</if>
</select>

使用_parameter代替传入的参数,不会报错。 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM