ibatis中if多条件查询以及sql中不等于,等于的用法

1、if多条件满足写法用and拼接

<if test="searchText != null and searchText != ''">

2、sql中不等于写法,用<![CDATA[xx <> 3 ]]>这种写法

例如字段xx不等于3:and  <![CDATA[xx <> 3 ]]>

3、当MyBatis 判断条件为等于的时候,常量需要加 .toString() 来转换,这种方法是稳定的,推荐使用,比如:

  1. <if test="newsImage != null and newsImage == '1'.toString()">  
  2.     <![CDATA[ and len(newsImage) > 0 ]]>  
  3. </if>  


猜你喜欢

转载自blog.csdn.net/menghuannvxia/article/details/79536399