您的位置:首页 > 数据库

Mybatis框架-24:动态SQL——set标签、foreach标签

2019-06-09 20:08 369 查看

set标签

可以去掉语句最后的那个逗号

[code]<update id="updateCustomer">
update `customer`
<set>
cust_name=#{cust_name},cust_profession=#{cust_profession},
</set>
where cust_id=#{cust_id}
</update>

foreach标签

做范围查询的时候,可以将传进来的范围值通过foreach标签 进行遍历

支持三种类型的传入

  • list
  • 对象属性
  • 数组
[code]<select id="getCustomers" parameterType="integer[]" resultType="com.ctbu.domain.Customer">
select * from `customer` where cust_id in
<foreach collection="array" open="(" close=")" separator="," item="ids">
#{ids}
</foreach>
</select>

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: