0

我有一个包含 6 列的表,如果其中 4 列相同,我希望我的插入命令进行更新。这是表格的示例

id  customer_id  sensor_id  user_unique_id        date        timestamps              
------  -----------  ---------  -----------------  ----------  -----------------------

 1           21         19  56346345645645654  2013-07-12  1373623091             
 2           21         18  34676546754756765  2013-07-12  1373623091             
 3           21         18  56754754754675755  2013-07-12  1373623047             
 4           21         18  54674567546754757  2013-07-12  1373623036,1373623037             
 5           21         18  54675647567547547  2013-07-12  1373623035        

如果我尝试插入

INSERT INTO table ('customer_id`,`sensor_is`,`user_unique_id`,`date`,`timestamps`)
VALUES ('21','19','56346345645645654','2013-07-12','1373623100')

我希望代码进行如下更新:

UPDATE table SET `timestemps`=`timestemps`+','+VALUES(timestemps)
WHERE customer_id = VALUES(customer_id)
AND sensor_is = VALUES(sensor_is)
AND user_unique_id = VALUES(user_unique_id)
AND date = VALUES(date)

我曾尝试使用 ON DUPLICATE KEY UPDATE 但我无法使所有列都独一无二..请帮助我:(

4

0 回答 0