Sometimes we need to copy a whole column of data from one field to another, or we need to copy the value of one of the fields from one table to a field in another table, this article lists some of the SQL statements, and the friends you need can refer to the following
Requirements: Copy one of the field contents of a table to a field in another table. Implementation of SQL statement 1: Code as follows: UPDATE File_manager_folder F1 left OUTER JOIN file_manager_folder f2 &NB Sp On f1.name = f2.name and F2.parentid = the SET F1.parentid = 54 WHERE f2.name is NULL and f1.id in (1,2,3); Implementation of SQL Statement 2: Code as follows: Update B set extra = A.extra from A join B on (a.id = b.id); Implementing SQL Statement 3: Code as follows: Update b Set b.sms = (select A.sms from a WHERE a.id = b.id) You need to determine that the IDs in two tables are primary keys or only Implementing SQL Statement 4: The code is as follows: UPDATE A SET a.sms = (select b.sms from b where a.id = b.id) WHERE EXISTS (select 1 from B W Here a.id = b.id); Implementation of SQL statement 5: Copy a table field data to another list of fields, you can write: Implement SQL statement 5: The code is as follows: UPDATE tb_1 INNER JOIN tb_2 on tb_1.tid = Tb_2.tid SET Tb_1.tco Ntent = tb_2.tcontent Attach: Same table replication requirements: Copy the contents of one field of the same table to another field Example 1: I want to copy the contents of a field from the article table to the B field in the article table. The SQL statement is: Code as follows: Update article set b=a; Example 2: Sometimes we need to copy a whole column of data from one field to another in a new field, which is simple, SQL can write:   Code as follows: UPDATE tb_1 SET content_target = Content_source; The following is roughly written: The code is as follows: Update {your_table} set {Source_field} = {Object_field} WHERE cause