In MySQL, How to Copy the Content of One Table to Another Table Within the Same Database

How to copy data from one table to another new table in MySQL?

This will do what you want:

INSERT INTO table2 (st_id,uid,changed,status,assign_status)
SELECT st_id,from_uid,now(),'Pending','Assigned'
FROM table1

If you want to include all rows from table1. Otherwise you can add a WHERE statement to the end if you want to add only a subset of table1.

How do I move the contents of one table to another in phpmyadmin? (same database)

Try exporting to a SQL file then change the table name and import it. The two tables have to be the same name.

Copy data into another table

If both tables are truly the same schema:

INSERT INTO newTable
SELECT * FROM oldTable

Otherwise, you'll have to specify the column names (the column list for newTable is optional if you are specifying a value for all columns and selecting columns in the same order as newTable's schema):

INSERT INTO newTable (col1, col2, col3)
SELECT column1, column2, column3
FROM oldTable

mysql copy complete row data from one table to another with different fields

You should use INSERT ... SELECT instead of INSERT ... VALUES and pass NULL for history_id:

INSERT INTO history_table
SELECT null, m.*
FROM master_table m
WHERE m.id = 8;

See the demo.

MySQL: Copy values from one to another table

In MySQL you can use joins to update a table with values from another table:

UPDATE table1 t1
JOIN table2 t2
ON t1.id = t2.id
SET t1.homepage = t2.homepage,
t1.name = t2.name

Copy a table to another table with different structure

Choose the columns to use and cast them to the necessary type in your select

insert into table1 (col1, col2, col3)
select cast(col1 as signed), col5, col7
from Table1_Temp

How to copy table between two models in Mysql workbench?

Your best option is probably to create a stripped down version of the model that contains the objects you want to carry over. Then open the target model and run File -> Include Model.... Select the stripped down source model and there you go.



Related Topics



Leave a reply



Submit