今天碰到一个数据库问题,需要批量更新一张表中的多个字段,字段值来源另外一张表!问了很多同事终于找到了一个非常简单的方法,一条sql解决了问题;sql如下:

  update 更新数据的表 a
           set (a.consignor_tm,
           a.src_zone_code,
           a.dest_zone_code,
           a.product_type_code) =
           (select b.consignor_tm,b.src_zone_code,b.dest_zone_code,b.product_type_code
           from 数据来源表 b
           where b.waybill_no = a.waybill_no);