mySQL表中的DATETIME单元有六个参数,分别是YEAR,MONTH,DAY,HOURS,MINUTES和SECONDS。
如何使用单个查询在多个单元格中单独替换它们?
实际上我已经获得了以下工作片段,取代了完整的"时间"多个细胞的一部分:
UPDATE wp_posts SET post_date = CONCAT(DATE(post_date),' HH:MM:SS');
但我无法修改如何修改它,例如,仅替换秒数。
目视:
---------------------------------------------
| original value | new value |
---------------------------------------------
| 2016-11-07 19:53:12 | 2016-11-07 19:53:00 | // only seconds have changed
---------------------------------------------
| 2016-11-07 19:53:12 | 2016-11-07 19:55:12 | // only minutes have changed
---------------------------------------------
| 2016-11-07 19:53:12 | 2016-11-07 20:53:12 | // only hours have changed
---------------------------------------------
| 2016-11-07 19:53:12 | 2016-11-22 19:53:12 | // only date has changed
---------------------------------------------
| 2016-11-07 19:53:12 | 2016-07-07 19:53:12 | // only month has changed
---------------------------------------------
| 2016-11-07 19:53:12 | 2009-11-07 19:53:12 | // only year has changed
---------------------------------------------
或
---------------------------------------------
| original value | new value |
---------------------------------------------
| 2016-11-07 19:53:12 | 2017-11-07 19:42:12 | // year and minutes have changed
---------------------------------------------
我认为这应该是一个查询,我可以决定哪些值(年,月,日,小时,分钟或秒)保持不变以及要改变什么。