INSERT INTO min_product ( shopid, productid , outward )
SELECT shopid, productid , outward
FROM main_product
WHERE shopid= '51'
ON DUPLICATE KEY UPDATE outward = ( SELECT sum(outward)
FROM main_product WHERE shopid= '51' )
main_product 表
productid outward shopid
333 2 44//present
343 4 44//present
353 5 44//present
363 1 44//present
373 2 44//not present
min_product 表
productid outward shopid
333 1 44
343 1 44
353 1 44
363 1 44
问题是它不会更新重复行而是插入新行?查询中有什么问题ON DUPLICATE KEY UPDATE