bugl
bugl
HomeLearnPatternsSearch
HomeLearnPatternsSearch

Loading lesson path

Learn/SQL/SQL References
SQL•SQL References

SQL INSERT INTO SELECT Keyword

Concept visual

SQL INSERT INTO SELECT Keyword

Pointer walk
two pointers
leftright102132436485116
left=0
right=6
1
3

Start at both ends

INSERT INTO SELECT Keyword

Previous

❮ SQL Keywords

Next

Insert Into Select

The INSERT INTO SELECT

command copies data from one table and inserts it into another table. The following SQL copies "Suppliers" into "Customers" (the columns that are not filled with data, will contain NULL):

Example

INSERT INTO Customers (CustomerName, City, Country)

SELECT SupplierName, City, Country FROM Suppliers;
The following SQL copies "Suppliers" into "Customers" (fill all columns):

Example

INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode,

Country)

SELECT SupplierName, ContactName, Address, City, PostalCode,

Country FROM Suppliers;
The following SQL copies only the German suppliers into "Customers":

Example

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

WHERE Country='Germany';

Previous

❮ SQL Keywords

Next

Previous

SQL INSERT INTO Keyword

Next

SQL IS NULL Keyword