批量sql语句

来源:互联网 发布:人力资源公司源码 编辑:程序博客网 时间:2024/05/18 01:55

批量修改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>
0 0
原创粉丝点击