Home / mySQL / How to copy one table data into another table using Mysql Query?

How to copy one table data into another table using Mysql Query?

Hi friends,
Today I’m going to tell you “how to copy table values from one database table values to another database table using MYSQL.” We can easly copy the one table values to another table in same database. This is easy and this purpose is used in allproject.

But in a big company keep the duplicate of existing database fully. But nobody try to copy the specified column or full column from the corresponding table in database to another database table in MYSQL. This concept is very easy and more useful.

You can copy data within a table and between tables with same database. And also you can copy the table data between different database in mysql. Here, can copy full data to another table or to copy specified field or column.


INSERT INTO databasename2.tablename(fieldname) select fieldname from databasename1.tablename

Step1:Create database and table

First create orginal database name as custa1. And also create table name orginal_table with id,table_name and sub_name. After creating table we insert the values to orginal table.

The orginal_table in custa1 is look like this:


Step2: Create second database and table

In second step: first create database “cusat2” and create table “table_copy” with id and name field for copying.

The table_copy in cusat2 is look like this:


Step3:Copy the first databse tablevalues to second database table.

Now we copy data of orginal_table from database custa1 to table_copy in cusat2 database. The mysql query is:

INSERT INTO cusat2.table_copy(name) select table_name from custa1.orginal_table


We can copy the full table details(full field) or we can copy specified fieldname from orginal database table to another database table.

If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

Leave a Reply

Your email address will not be published. Required fields are marked *