更新单个表中从column1到column2的值替换查询

时间:2012-10-12 09:20:34

标签: mysql

我想将已解决的时间更新为已创建的时间和状态=已解决的ID列表。

+-------+---------------------+---------------------+--------+
| id    | created             | Resolved            | Status |
+-------+---------------------+---------------------+--------+
| 15367 | 2012-07-11 21:15:05 | 1970-01-01 00:00:00 | new    |
| 15370 | 2012-07-11 21:21:12 | 1970-01-01 00:00:00 | new    |
| 15374 | 2012-07-11 21:27:28 | 1970-01-01 00:00:00 | new    |
| 15377 | 2012-07-11 21:31:06 | 1970-01-01 00:00:00 | new    |
+-------+---------------------+---------------------+--------+

2 个答案:

答案 0 :(得分:2)

UPDATE查询有问题吗?

UPDATE myTable SET Resolved = Created, Status = 'Resolved' 
WHERE ID IN (15367,15370,15374 ,15377)

See this SQLFiddle

答案 1 :(得分:0)

尝试此查询,

更新table_name set Resolved = created,status ='resolved'WHERE id in(15367,15370,15374,15377)