列的SUM不与MySQL替换

时间:2013-03-16 20:55:45

标签: mysql replace key duplicates

此查询假设每次执行时只更新currentStock。但是当我第一次执行查询时,currentStock变为0而不是100.对于我来说,1和2查询都不起作用。

1)

INSERT INTO Store_Items (storeID, itemId,itemName)
VALUES ('STR004', '4534','K40')
ON DUPLICATE KEY UPDATE currentStock = currentStock + 100;

2)

REPLACE INTO Store_Items
     SET storeID ='STR004',
         itemId='4534',
         itemName='K40',
         SUM(currentStock) as 'Total',
         reorderLevel=1000;

0 个答案:

没有答案