Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy one column from one database to another

I need to copy the content from a column in one database into the matching column in another, so that the same content goes in the record with the same ID. Something like the following pseudo stuff:

SET database2.table1.columnA TO database1.table1.columnA WHERE database2.id = database1.id
like image 746
Mild Fuzz Avatar asked Jan 15 '12 21:01

Mild Fuzz


People also ask

How do I copy a column from one database to another in SQL?

Using SQL Server Management StudioOpen the table with columns you want to copy and the one you want to copy into by right-clicking the tables, and then clicking Design. Click the tab for the table with the columns you want to copy and select those columns. From the Edit menu, click Copy.

How do I copy a column from one database to another in mysql?

To copy data from one table to another, use the INSERT INTO statement. Note, that you can specify the columns to be copied.

How do I copy data from one table of one database to another table of another database in SQL?

Enter the data source, server name and select the authentication method and the source database. Click on Next. Now, enter the destination, server name, authentication method and destination database then click on Next. Select 'Copy data from one or more tables or views' option in the next window and click on Next.

How do I copy a column to another column?

Move or copy just the contents of a cell Select the row or column that you want to move or copy. In the cell, click where you want to paste the characters, or double-click another cell to move or copy the data. or press Ctrl+V. Press ENTER.


1 Answers

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`
like image 151
Elgoots Avatar answered Sep 18 '22 21:09

Elgoots