国产日产欧产精品网站|2022仙踪林官网老狼信息|天天澡天天揉揉Av在线|国产精品成人久久久久久久

MyBatis框架

5.4 set

  • set 主要是用于解決修改操作中SQL語句中可能多出逗號的問題

<update id="updateEmpByConditionSet">

?????????????????? update? tbl_employee?

?????????????????? <set>

??????????????????????????? <if test="lastName!=null &amp;&amp; lastName!=&quot;&quot;">

???????????????????????????????????? ?last_name = #{lastName},

??????????????????????????? </if>

??????????????????????????? <if test="email!=null and email.trim()!=''">

???????????????????????????????????? ?email = #{email} ,

??????????????????????????? </if>

??????????????????????????? <if test="&quot;m&quot;.equals(gender) or &quot;f&quot;.equals(gender)">

???????????????????????????????????? gender = #{gender}

??????????????????????????? </if>

?????????????????? </set>

?????????????????? ?where id =#{id}

???????? </update>

 

5.5 choose(when、otherwise)

  • choose 主要是用于分支判斷,類似于java中的switch case,只會滿足所有分支中的一個

<select id="getEmpsByConditionChoose" resultType="com.atguigu.mybatis.beans.Employee">

????????????? select id ,last_name, email,gender from tbl_employee

????????????? <where>

???????????????????? <choose>

??????????????????????????? <when test="id!=null">

?????????????????????????????????? id = #{id}

??????????????????????????? </when>

??????????????????????????? <when test="lastName!=null">

?????????????????????????????????? last_name = #{lastName}

??????????????????????????? </when>

??????????????????????????? <when test="email!=null">

?????????????????????????????????? email = #{email}

??????????????????????????? </when>

??????????????????????????? <otherwise>

?????????????????????????????????? ?gender = 'm'

??????????????????????????? </otherwise>

???????????????????? </choose>

????????????? </where>

</select>

 

 

临清市| 青州市| 盐亭县| 江川县| 家居| 泰来县| 大连市| 天长市| 二连浩特市| 台前县| 襄垣县| 谢通门县| 富源县| 宣威市| 古田县| 土默特右旗| 西乌| 南城县| 镇安县| 德安县| 宜良县| 陵川县| 蒙阴县| 沅江市| 伊宁县| 昌平区| 都昌县| 大丰市| 西峡县| 崇仁县| 怀化市| 新密市| 南京市| 金华市| 苏尼特左旗| 兰考县| 阿城市| 新巴尔虎左旗| 滨海县| 洛隆县| 凤冈县|