How Mysql updates some fields of another table based on data from one table
This article mainly introduces how Mysql updates some fields of another table according to the data of one table. It is very detailed and has certain reference value. Friends who are interested must read it.
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 coding', 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 coding', 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 creation time of the creator to the T_U_TEMPLATE table UPDATE T_U_TEMPLATE a minute templated create b SET a.CREATE_TIME=b.CREATE_TIME WHERE a.TEMPLATE_CODE = b. OBJECTCTED ID address update T_U_TEMPLATE a makeshift project create b SET a.CREATE_BY=b.OPERATER_NAME WHERE a.TEMPLATE_CODE = b.OBJECT_ID The above is all the content of the article "how Mysql updates some fields of another table based on one table data". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!