这个INSERT INTO SELECT
命令从一个表复制数据并将其插入到另一表中。
以下 SQL 将 "Suppliers" 复制到 "Customers"(未填充数据的列将包含 NULL):
INSERT INTO Customers (CustomerName, City, Country)
SELECT SupplierName, City, Country FROM Suppliers;
以下 SQL 将 "Suppliers" 复制到 "Customers"(填充所有列):
INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country)
SELECT SupplierName, ContactName, Address, City, PostalCode, Country FROM Suppliers;
以下 SQL 仅将德国供应商复制到"Customers":
INSERT INTO Customers (CustomerName, City, Country)
SELECT SupplierName, City, Country FROM Suppliers
WHERE Country='Germany';
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!