MySQL的条件重复密钥更新

时间:2015-07-07 14:51:34

标签: php mysqli

我正在尝试使用单个mysqli查询实现更新乘法行。到目前为止我所做的是:

 $sql="INSERT INTO history_table (image_canvas_channel, start_image_time, end_image_time) VALUES ($image_canvas_channel , $start_image_time, $end_image_time) ON DUPLICATE KEY UPDATE start_image_time = IF(image_canvas_channel = $image_canvas_channel, start_image_time = $start_image_time,) , end_image_time = IF(image_canvas_channel = $image_canvas_channel, end_image_time = $end_image_time,)";
  

您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以便在第1行附近使用正确的语法,end_image_time = IF(image_canvas_channel = 152,end_image_time = 363365,)'。

0 个答案:

没有答案