MYSQL replacement time (year, month, day) field, the time and minute remain unchanged, mysql minute and second
Statement 1: update sas_order_supply_month_pay set RECEIVE_TIME = REPLACE (RECEIVE_TIME, DATE_FORMAT (RECEIVE_TIME, '% Y-% m-% D '), (select PERIOD_END from sas_task_supply_month_pay_period where belong = '000000' and CREATE_TIME like '% 1729%') where ORDER_CODE = 'po201707130115 ';
Statement 2: update sas_order_supply_month_pay set RECEIVE_TIME = ADDTIME (select PERIOD_END from region where belong = '000000' and CREATE_TIME like '% 1729%') + interval 0 hour, time (RECEIVE_TIME )) where ORDER_CODE = 'po201707130115 ';
Statement 3: update sas_order_supply_month_pay set RECEIVE_TIME = concat (select PERIOD_END from region where belong = '000000' and CREATE_TIME like '% 1729%'), '', DATE_FORMAT (RECEIVE_TIME, '% H: % I: % s') where ORDER_CODE = 'po201707130115 ';
Note: The RECEIVE_TIME field of the sas_order_supply_month_pay table is in the format of "12:13:16". The PERIOD_END field of the sas_task_supply_month_pay_period table is in the format ",
After the command is executed, change RECEIVE_TIME to "12:13:16 ".
Incorrect syntax: update sas_order_supply_month_pay set RECEIVE_TIME = DATE_FORMAT (concat (select PERIOD_END from region where belong = '2016' and CREATE_TIME like '% 1729% '),'', (select DATE_FORMAT (RECEIVE_TIME, '% H: % I: % s') from sas_order_supply_month_pay where ORDER_CODE = 'po201707130115'), "yyyy-MM-dd % H: % I: % S ") where ORDER_CODE = 'po201707130115 ';
Error message: [Err] 1093-You can't specify target table 'sas _ order_supply_month_pay 'for update in FROM clause
Error analysis:
Error statement: (select DATE_FORMAT (RECEIVE_TIME, '% H: % I: % s') from sas_order_supply_month_pay where ORDER_CODE = 'po201707130115 ')
This statement can be executed independently, but an error is reported when it is executed together. guess: the table and subquery cannot be modified in the same table?