从一个查询中可以做到吗?
将多个选定的行信息从一个表插入到另一个表中 喜欢:
Customers (register_no,CustomerName, City, Country)
Suppliers(register_no,SupplierName, City, Country)
INSERT INTO Customers (register_no,CustomerName, City, Country)
SELECT register_no SupplierName, City, Country FROM Suppliers where register_no=10;
但有一次可以选择register_no = 1,register_no = 3,register_no = 10; 在一个查询中
答案 0 :(得分:4)
是的,可以在
中使用INSERT INTO Customers (register_no,CustomerName, City, Country)
SELECT register_no SupplierName, City, Country FROM Suppliers where register_no in (1,3,10)
答案 1 :(得分:2)
您可以使用IN
子句。
INSERT INTO Customers (register_no,CustomerName, City, Country)
SELECT register_no SupplierName, City, Country FROM Suppliers where register_no IN (1,3,10);