The following code introduces MySQL to update some fields of another table based on the data of one table. The specific code is as follows: DROP TABLE IF EXISTS T_U_TEMPLATE; -- Template table CREATE TABLE T_U_TEMPLATE ( ID INT NOT NULL AUTO_INCREMENT comment 'Template table ID', TEMPLATE_CODE VARCHAR(50) BINARY comment 'Template code', TEMPLATE_NAME VARCHAR(300) BINARY comment 'Template name', CREATE_TIME datetime DEFAULT NULL COMMENT 'Creation time', CREATE_BY varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'Creator' , UPDATE_BY varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT 'Updater' , UPDATE_DATE datetime COMMENT 'Update time', constraint PK_U_TEMPLATE primary key (ID) )DEFAULT CHARSET=utf8 comment 'Template table'; DROP TABLE IF EXISTS TEMPLATE_TEMP_CREATE; -- Template temporary table CREATE TABLE TEMPLATE_TEMP_CREATE ( ID INT NOT NULL AUTO_INCREMENT comment 'Template table ID', OBJECT_ID VARCHAR(50) BINARY comment 'Template code', OPERATER_NAME varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'Updater' , CREATE_TIME datetime NOT NULL COMMENT 'Update time', constraint PK_U_TEMPLATE primary key (ID) )DEFAULT CHARSET=utf8 comment 'Template temporary table'; -- Modify the creator's creation time to the T_U_TEMPLATE table UPDATE T_U_TEMPLATE a,TEMPLATE_TEMP_CREATE b SET a.CREATE_TIME=b.CREATE_TIME WHERE a.TEMPLATE_CODE = b.OBJECT_ID; UPDATE T_U_TEMPLATE a,TEMPLATE_TEMP_CREATE b SET a.CREATE_BY=b.OPERATER_NAME WHERE a.TEMPLATE_CODE = b.OBJECT_ID; Summarize The above is what I introduced to you about Mysql updating certain fields of another table based on the data of one table. I hope it will be helpful to you. If you have any questions, please leave me a message and I 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:
|
<<: Key knowledge summary of Vue development guide
>>: Detailed steps for porting busybox to build a minimal root file system
Database stored procedures DROP PROCEDURE IF EXIS...
Is it the effect below? If so, please continue re...
Table of contents 1. Open WeChat Pay 1.1 Affiliat...
Table of contents 1. Component switching method M...
Maybe everyone knows that js execution will block...
Table of contents 1. Database Operation 1.1 Displ...
The skills that front-end developers need to mast...
WeChat applet's simple calculator is for your...
What is em? em refers to the font height, and the ...
HTML structure <body> <div class="w...
As you build and scale your Django applications, ...
Preface The electricity in my residence has been ...
Today I am a little confused about <a href=&quo...
Password Mode PDO::__construct(): The server requ...
Preface Some of the earlier codes on Github may r...