MyBatis if判斷條件有特殊需求時的問題


  剛遇到一個問題!!!

  平常寫MyBatis if語句時,一般就不等於空並且不等於“ ”即

<if test="pd.shop_id!=null and pd.shop_id!=''>
   and
   shop_id = #{pd.shop_id}
</if>

  但如果這時需要添加一個條件,同時滿足三個條件的情況,且最后一個條件是某某等於0,可以這樣寫

<if test="pd.shop_id!=null and pd.shop_id!=''and pd.super_id=='0'.toString()">
            and
            shop_id = #{pd.shop_id}
        </if>

  加個toString就行了。

 

參考文章:https://blog.csdn.net/ziany/article/details/79728016


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM