Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

INSERT INTO SELECT

INSERT INTO SELECT

The INSERT INTO SELECT command duplicates data from the “Suppliers” table into the “Customers” table, with unfilled columns containing NULL values.

Example

INSERT INTO Customers (CustomerName, City, Country)
SELECT SupplierName, City, Country FROM Suppliers;

The following SQL replicates data from the “Suppliers” table into the “Customers” table, populating all columns:

Example

INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country)
SELECT SupplierName, ContactName, Address, City, PostalCode, Country FROM Suppliers;

The provided SQL selectively duplicates only the German suppliers into the “Customers” table:

Example

INSERT INTO Customers (CustomerName, City, Country)
SELECT SupplierName, City, Country FROM Suppliers
WHERE Country=‘Germany’;