表对表数据插入
文章目录

Example

1
2
INSERT INTO Customers (CustomerName, Country)
SELECT SupplierName, Country FROM Suppliers;
1
2
3
INSERT INTO Customers (CustomerName, Country)
SELECT SupplierName, Country FROM Suppliers
WHERE Country='Germany';

注意 SELECT 的行一定要和 INSERT 语句中写的行相同

但是插入语句的参数并不要求包含所有的列

对于语句

1
INSERT INTO Customers (CustomerName, Country)

来说, Customers 表可能不仅仅只有两列