Writing method 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='1729' and CREATE_TIME like '%2017-07-12%')) where ORDER_CODE='PO201707130115'; Writing method 2: update sas_order_supply_month_pay set RECEIVE_TIME = ADDTIME ((select PERIOD_END from sas_task_supply_month_pay_period where belong='1729' and CREATE_TIME like '%2017-07-12%')+interval 0 hour,time(RECEIVE_TIME)) where ORDER_CODE='PO201707130115'; Writing method 3: update sas_order_supply_month_pay set RECEIVE_TIME = concat((select PERIOD_END from sas_task_supply_month_pay_period where belong='1729' and CREATE_TIME like '%2017-07-12%'),' ',DATE_FORMAT(RECEIVE_TIME,'%H:%i:%S')) where ORDER_CODE='PO201707130115'; Description: The format of the RECEIVE_TIME field in the as_order_supply_month_pay table is "2017-06-16 12:13:16", and the format of the PERIOD_END field in the sas_task_supply_month_pay_period table is "2017-07-12", After execution, Wrong way of writing: update sas_order_supply_month_pay set RECEIVE_TIME = DATE_FORMAT(concat((select PERIOD_END from sas_task_supply_month_pay_period where belong='1729' and CREATE_TIME like '%2017-07-12%'),' ',(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'; Wrong writing error: [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 individually, but an error occurs when it is executed together. My guess is: the modified table and the subquery cannot be the same table? The above is the implementation method of replacing the MYSQL time (year, month, day) field with unchanged hours, minutes and seconds introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: How to simplify Redux with Redux Toolkit
>>: How to use Nginx to solve front-end cross-domain problems
1. Priority of multiple servers For example, if e...
This article mainly introduces the effect of div ...
With a lot of CSS experience as a web designer, we...
Table of contents Preface 1. Preparation - Server...
Preface Tomcat is an excellent Java container, bu...
How can you forget lazy loading of routes that al...
Table of contents 1. Brief Overview 2. JSON basic...
Temporary tables and memory tables A memory table...
The commonly used Oracle10g partitions are: range...
Preface I have been working on some front-end pro...
Table of contents The pitfalls Filling method Wha...
Method 1: Use the SET PASSWORD command mysql -u r...
Table of contents Avoid repetitive rendering loop...
There is no need to say much about the difference...
<br />In the previous article, I introduced ...