0

我正在尝试在我的测试服务器上执行以下代码:

Insert into CURRENT values (2, 962, 123.45, 30, 0, '2012-06-08 10:41:23', 100, 80, 
  'Rainy', 120, 50, '2012-06-08 10:14:27', 19300.10, 150.27, 30000, null, 1, 0) 
  ON DUPLICATE KEY UPDATE (WEIGHT, TWEIGHT, OVERRIDE, WEATHER_TS, TEMP, HUMIDITY, 
CONDITIONS, T_HIGH, T_LOW, TRAVELTIME, LOAD, PRICE, AVAILABLE, FREQUENCY, ACTIVE, DIS);

2962是外键,'2' 是主键 (ID)。

我一直收到(之前重量的错误。

4

2 回答 2

2

根据MySQL 手册,您做得不太对。在该UPDATE部分中,您需要将其视为常规更新查询。所以它看起来像:

ON DUPLICATE KEY UPDATE WEIGHT=2, TWEIGHT=962...
于 2012-06-08T14:58:50.603 回答
1

像这样使用它

Insert into CURRENT 
values (2, 962, ...) 
ON DUPLICATE KEY UPDATE WEIGHT = 2, TWEIGHT = 962, ...
于 2012-06-08T14:58:01.680 回答