mybatis mapper.xml 里的<if>标签可以嵌套吗

如题所述

第1个回答  推荐于2018-01-23

完全可以

<!-- 根据条件模糊查询 -->
<select id="findTrackerByPuzzy" parameterType="java.util.Map"
resultMap="trackerDevice_resultMap">
select
d.*,u.real_name as u_name
from tb_tracker_device d
left outer join
tb_user u
on u.id=d.user_id
<where>
<if test="condition !=null and condition !=''">
(d.tracker_id like
CONCAT('%',#{condition},'%')
or
d.number like
CONCAT('%',#{condition},'%')
or 
d.imei like
CONCAT('%',#{condition},'%')
or 
d.sim like
CONCAT('%',#{condition},'%')
or 
d.telephone like
CONCAT('%',#{condition},'%')
or 
(u.real_name like 
           CONCAT('%',#{condition},'%')
           <if test="channel !=null">
and u.channel=#{channel}
</if>
           ))
</if>
<if test="channel !=null">
and d.channel=#{channel}
</if>
</where>
order by d.sync_time desc
</select>

本回答被网友采纳
第2个回答  2017-08-23
不可以的。本回答被提问者采纳
第3个回答  2017-11-19
4K显示器吗
第4个回答  2015-01-08
这个还真没试过,应该是可以的,不过别把mapper搞的太复杂,以后维护的时候你会哭的

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网