mybatis動態SQL標籤的使用

1.insert標籤

2.update標籤

3.delete標籤

4.select標籤

5.sql標籤

6.include標籤

7.bind標籤  參數綁定,比如like查詢

8.if標籤

9.where標籤  where 標記會自動將其後第一個條件的and或者是or給忽略掉

<where>

      <if test="id != null ">id=#{id}</if>

      <if test="name != null and name.length()>0" >and name=#{name}</if>

      <if test="gender != null and gender.length()>0">and gender = #{gender}</if>

</where>

10.foreach標籤

11.trim標籤

<select id="queryBy" resultType="com.scme.pojo.User" parameterType="com.scme.pojo.User">
                 select * from user 
                 <trim prefix="WHERE" prefixOverrides="AND |OR ">
                          <if test="username!=null and password!=null">
                             and username=#{username} and password=#{password}
                         </if>
                </trim>
                 <!-- 效果同上
          <where>
                         <if test="username!=null and password!=null">
                             and username=#{username} and password=#{password}
                         </if>
                 </where> -->
</select>

12.choose when otherwise標籤

13.set標籤

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章