美文网首页
update...join

update...join

作者: 帮我的鸵鸟盖个章 | 来源:发表于2018-12-24 11:42 被阅读0次

update...join

<!--sales插入数据时,根据vins更新inventory的number-->
<update id="update">
    UPDATE epc_inventory i JOIN
    (
      SELECT c.material_code,c.material_name,SUM(c.dh) number FROM epc_mes_components c
      JOIN  epc_mes_ovet v
      ON c.item_id = v.item_id
      WHERE v.vin IN (
        <foreach collection="vins" item="vin" index="index" separator=",">
            #{vin}
        </foreach>
      )
     GROUP BY c.material_code
    ) t
    ON t.material_code = i.material_code
    SET i.number = i.number + t.number
    WHERE i.country_area = #{countryArea}
</update>

相关文章

网友评论

      本文标题:update...join

      本文链接:https://www.haomeiwen.com/subject/nqgakqtx.html