MYSQL replacement time (year, month, day) field, the time and minute remain unchanged, mysql minute and second

Source: Internet
Author: User

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?

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.