SQL INSERT IN SELECT Keyword
❮ Riferimento alle parole chiave SQL
INSERIRE IN SELECT
Il INSERT INTO SELECT
comando copia i dati da una tabella e li inserisce in un'altra tabella.
Il seguente SQL copia "Fornitori" in "Clienti" (le colonne che non sono riempite di dati conterranno NULL):
Esempio
INSERT INTO Customers (CustomerName,
City, Country)
SELECT SupplierName, City, Country FROM Suppliers;
Il seguente SQL copia "Fornitori" in "Clienti" (riempire tutte le colonne):
Esempio
INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode,
Country)
SELECT SupplierName, ContactName, Address, City, PostalCode,
Country FROM Suppliers;
Il seguente SQL copia solo i fornitori tedeschi in "Clienti":
Esempio
INSERT INTO Customers (CustomerName,
City, Country)
SELECT SupplierName, City, Country FROM Suppliers
WHERE Country='Germany';
❮ Riferimento alle parole chiave SQL