SQL Tutorial – Copy Rows from One Table into Another.

Spread the love

You want to copy the rows from one table into another using a query. In our previous post, we saw how to copy the column names from another table with copying the data , and at this moment that table is empty. Now let’s copy the data from the employee table to populate it.

Actors – Empty Table

Employees –

Solution –

To copy the data, we can use the INSERT statement followed by a query that selects all the rows that we want.

INSERT INTO
    Actors (id, name, gender, salary)
SELECT
    id,
    name,
    gender,
    salary
FROM
    employees

If you want, you can also filter data using the WHERE clause but since we want to copy all of the data from the employees table, I did not used it here.

Rating: 1 out of 5.

Leave a Reply