您的位置:首页 > 数据库

批量sql语句

2016-04-08 10:43 302 查看
批量修改MySQL(orcal)

<!-- 修改查询状态为0-->
<update id="updateCarOptions"  parameterType="java.util.List">
UPDATE T_B_CAR_OPTION  carOption SET carOption.STATE = 0
<where>
carOption.ID in (
<foreach  item="id" index="index" collection="array"
separator=","> #{id} </foreach>
)
</where>
</update>


批量插入

<select id="insertCheckingItems" parameterType="java.util.List">
INSERT INTO T_B_CHECKING_ITEM (ID,CAR_TYPE
)
<foreach collection="list"  item="item" separator="union">
(SELECT  #{item.id,jdbcType=VARCHAR},
#{item.carType,jdbcType=VARCHAR}from dual)
</foreach>
</select>


批量查询

<!-- 批量查询 -->
<select id="queryServiceList" resultMap="BaseResultMap">
select * from  T_B_SERVICESTATION  o
where 1=1
<if test="company != null and company !=''" >
AND o.COMPANY  LIKE '%' || #{company} || '%'
</if>
<if test="office != null">
AND
<foreach  item="item" collection="office" separator=" or ">
o.OFFICE = #{item}
</foreach>
</if>
order by ADD_TIME desc
</select>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: