mysql-update多表关联更新实战

    update
    A sp -- 主表
    left join B cc on cc.id = sp.customer_commodity_id -- 替他表
    left join C c on c.commodity_code = cc.commodity_code and c.status=3
    left join D cp on cp.commodity_id = c.id and cp.is_deleted = 1 and cp.is_default=1 and cp.status=3
    set sp.unit_code = cp.unit_code --更新值
    where sp.unit_code is null and cp.unit_code is not null;

     where 条件放在最后,不然报错!

上一篇:easyui DataGrid表体单元格跨列rowspan


下一篇:微软发布TX(LINQ To Logs And Traces)