INSERT data from another table using SELECT

suggest change
INSERT INTO Customers (FName, LName, PhoneNumber)
SELECT FName, LName, PhoneNumber FROM Employees

This example inserts all Employees into the Customers table. Because the tables have different columns, name the columns to insert and the columns to select. Corresponding columns need not have the same name, but they must have compatible types. This example assumes that Id is generated automatically (IDENTITY in SQL Server, AUTO_INCREMENT in MySQL, and so on).

If two tables have the same number of columns, in the same order, with compatible types, you can copy every row with:

INSERT INTO Table1
SELECT * FROM Table2

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents