多了个 and : where code like '%30%' and (Name like '%abb%' or rev like '%abb%')
+1 不就直接写不就行了么? <select id="getExampleList" resultType="example"> SELECT * FROM <include refid="tableName" /> WHERE code LIKE '%30%' AND (Name LIKE '%abb%' OR rev like '%abb%') </select>
其實我要的是這樣的呀 <isNotEmpty prepend="AND" property="aa" open="(" close=")"> aa like '%$aa$%' <isNotEmpty prepend="OR" property="bb"> bb like '%$bb$%' </isNotEmpty> </isNotEmpty> 唉
where 后面那个 and??? 这种问题自己能搞定的啊
where and code like '%30%' and (Name like '%abb%' or rev like '%abb%')where code like '%30%' and (1=1 <isNotEmpty prepend="AND" property="aa" open="(" close=")"> code like '%$aa$%' </isNotEmpty> <isNotEmpty prepend="OR" property="bb"> bb like '%$bb$%' </isNotEmpty> )
where code like '%30%' and (Name like '%abb%' or rev like '%abb%')
<select id="getExampleList" resultType="example">
SELECT * FROM
<include refid="tableName" />
WHERE code LIKE '%30%' AND (Name LIKE '%abb%' OR rev like '%abb%')
</select>
还有一种方式传值$$
将(#PARAMETER:VACAHR#)替换为($PARAMETER:VACAHR$
就OK了
##形式相当于预编译 传递的参数不能被引用
$$直接解析为字符串
<isPropertyAvailable prepend="" property="PARDEPTID">
<isGreaterThan prepend="and" property="PARDEPTID" compareValue="-1">
a.PARDEPTID = #PARDEPTID#
</isGreaterThan>
</isPropertyAvailable>
</dynamic>MyBatis 3<trim prefix="where" prefixOverrides="and |or " suffixOverrides="">
<if test="DID != null and DID > 0">
and a.DID = #{DID,javaType=int,jdbcType=INTEGER}
</if>
</trim>
可以参考FortuneJ
参考地址www.cnblogs.com/mail-ricklee
<isNotEmpty prepend="AND" property="aa" open="(" close=")">
aa like '%$aa$%'
<isNotEmpty prepend="OR" property="bb">
bb like '%$bb$%'
</isNotEmpty>
</isNotEmpty>
唉
这种问题自己能搞定的啊
<isNotEmpty prepend="AND" property="aa" open="(" close=")">
code like '%$aa$%'
</isNotEmpty>
<isNotEmpty prepend="OR" property="bb">
bb like '%$bb$%'
</isNotEmpty>
)