动态SQL

<if>:
<where>:
 
select 字段名  from 表名        
<where>         
    <if  test= " username != null ">
           <!-- 字段名 = #{参数名} -->
           and username = #{username}
    </if>  
</where>


<foreach> : 遍历数组或集合 
<!-- 通过动态sql foreach 批量删除-->
<delete id="deleteAll">
     delete from tlias.emp where id in
  <foreach collection="ids" item="id" separator="," open="(" close=")">
    #{id}
  </foreach>
</delete>
<!-- 通过动态sql foreach 批量删除-->
delete from 表名  where 字段名 in

< foreach collection = 集合名字 item = "id" separator = "," opem="("  close=")"  >
        #{id}
</foreach>
<set>: 此标签 通常只在 更新时需要用到s

update  表名
<set>
<if test = " username !=null and username != '' ">
   username = #{username}
</if>
<if test = "password != null and password != '' ">
   password = #{password}
</if>
</set>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值