Copy one column from one database to another Copy one column from one database to another sql sql

Copy one column from one database to another


MySQL uses syntax:

update database1.table1, database2.table1set database1.table1.columnA = database2.table1.columnAwhere database1.table1.id = database2.table1.id;


You can use JOIN in an UPDATE statement:

UPDATE table1 t1 JOIN database1.table1 as t2 ON   t1.id = t2.idSET   t1.columnA = t2.columnA


if not identical columns for other people you can use the below:

USE `old_database`;INSERT INTO `new_database`.`new_table`(`column1`,`column2`,`column3`)SELECT `old_table`.`column2`, `old_table`.`column7`, `old_table`.`column5` FROM `old_table`