mysql 注意点汇总

方式一:

UPDATE A a, B b
SET a.name = b.my_name
WHERE a.id = b.id

方式二:

UPDATE 
  supplierInfo s,
  (SELECT 
    a.*,b.* 
  FROM
    hbkysuptest a 
    LEFT JOIN purchaserthirdsupplier b 
      ON a.supplierId = b.thirdsupplierNo) t 
SET
  s.supplierCategory = t.categoryName 
WHERE s.supplierNo = t.supplierNo 
AND t.supplierNo !='' AND t.supplierNo IS NOT NULL
AND (s.supplierCategory IS NULL OR s.supplierCategory = '')
AND t.categoryName IS NOT NULL AND t.categoryName !=''
AND s.supplierType = 2 -- 合格供应商
AND s.isBacklist!=1    -- 非禁用
AND s.isstart!=1       -- 非停用

你可能感兴趣的:(mysql 注意点汇总)