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