Requirement: Copy one table field content to a field in another table.
Implementing SQL Statement 1:
UPDATE file_manager_folder f1left OUTER JOIN file_manager_folder f2 on f1.name = f2.name and F2.parentid = 54SET F1.PA Rentid = F2.name is NULL and f1.id in (All-in-all);
Implementing SQL Statement 2:
Update B Set extra = A.extra from A join B on (a.id = b.id);
I tried, like, an error.
Implementing SQL Statement 3:
Update B Set b.sms = (select A.sms from a WHERE a.id = b.ID)
You need to determine whether the IDs in the two tables are primary keys or unique
Implementing SQL Statement 4:
UPDATE A SET a.sms = (select b.sms from b where a.id = b.ID) where EXISTS (select 1 from b where a.id = b.ID);
Implementing SQL Statement 5:
To copy one table field data to another, you can write:
Implementing SQL Statement 5:
UPDATE tb_1 INNER JOIN tb_2 on tb_1.tid = Tb_2.tidset tb_1.tcontent = tb_2.tcontent
Attached: copy of the same table
Requirement: Copy the contents of one field in the same table into another field
Example 1:
I want to copy the contents of the A field in the article table to the B field in the article table. The SQL statement is:
Update article set b=a;
Example 2:
Sometimes we need to copy the entire column of data from one field to another in a new field, which is simple enough for SQL to write:
UPDATE tb_1 SET content_target = Content_source;
The approximate wording is as follows:
Update {your_table} set {Source_field} = {Object_field} WHERE cause
In the end, I used
UPDATE k1.tb1 kt1inner JOIN k2.tb2 kt2 on kt1.id = Kt2.idset Kt1.sex = kt2.sex
Database K1 tb1 Table synchronization database K2 TB2 table corresponding ID of sex
MySQL different library table field data replication