批量sql语句

批量修改MySQL(orcal)


    <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>

你可能感兴趣的:(随记)