国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

SQL Server中Insert與Select的組合使用

瀏覽:162日期:2023-11-04 08:46:42

SQL Server中有示例數據庫Northwind。新建表Sales用于存儲銷售信息,字段為EmployeeID,ProductID,SupplierID,CustomerID,OrderDate,UnitPrice,Total,Quantity,Discount。

下面的語句從Orders,Order Details, Employees,Products, Suppliers, Customers表選擇相應的

數據插入Sales表:

insert into Sales(EmployeeID,ProductID,SupplierID,CustomerID,OrderDate,UnitPrice,Total,Quantity,Discount) select e.EmployeeID, p.ProductID, s.SupplierID,c.CustomerID, o.OrderDate, od.UnitPrice,od.Quantity*od.UnitPrice*(1.0-od.Discount)Total,Od.Quantity, od.Discountfrom Orders o,[Order Details] od, Employees e,Products p, Suppliers s, Customers cwhere (o.OrderID = od.OrderID) and(o.EmployeeID = e.EmployeeID) and(o.CustomerID = c.CustomerID) and(od.ProductId = p.ProductID) and(p.SupplierID = s.SupplierID);go

標簽: Sql Server 數據庫
主站蜘蛛池模板: 额济纳旗| 余江县| 年辖:市辖区| 梅河口市| 原阳县| 乌拉特中旗| 云南省| 遂昌县| 汾西县| 婺源县| 大足县| 澄江县| 重庆市| 保康县| 峨眉山市| 甘孜县| 报价| 浑源县| 喀喇沁旗| 阜城县| 竹溪县| 金平| 穆棱市| 西和县| 龙江县| 富民县| 兰州市| 浦县| 年辖:市辖区| 大港区| 宁武县| 林芝县| 佛山市| 新宁县| 高淳县| 昭苏县| 茶陵县| 靖宇县| 喜德县| 雷波县| 阿合奇县|