首页 > 数据库技术 > 详细

MyBatis动态SQL之一使用 if 标签和 choose标签

时间:2018-01-16 21:42:09      阅读:488      评论:0      收藏:0      [点我收藏+]

bootstrap react https://segmentfault.com/a/1190000010383464

xml 中 < 转义 to thi tha 

<if test="pricehigh!=null">
and price &lt; #{pricehigh,jdbcType=INTEGER}
</if>

 

MyBatis动态SQL之一使用 if 标签和 choose标签

  1. <select id="getItems" parameterType="com.ipro.shopping.to.IntegerEntity" resultType="itemsType">  

  2.        select * from itemsType  

  3.        <where>  

  4.           <!--方式一使用choose的方式查询-->  

  5.          <!-- <choose>  

  6.              <when test="parentId !=0 ">parentTypeId=#{parentId}</when>  

  7.              <when test="parentId==0">parentTypeId is null</when>  

  8.           </choose> -->  

  9.          <!--方式二使用if的方式查询-->  

  10.           <if test="parentId!=0">  

  11.              parentTypeId=#{parentId}  

  12.           </if>  

  13.           <if test="parentId==0">  

  14.             parentTypeId is null  

  15.           </if>  

  16.        </where>  

  17.     </select>  

MyBatis动态SQL之一使用 if 标签和 choose标签

原文:https://www.cnblogs.com/cnchengv/p/8297670.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!