新聞中心
SQL Server insert語句是SQL中最常見也是最重要的語句之一,下文將為您解讀SQL Server insert與Select組合使用的方法,供您參考。

在定州等地區(qū),都構建了全面的區(qū)域性戰(zhàn)略布局,加強發(fā)展的系統性、市場前瞻性、產品創(chuàng)新能力,以專注、極致的服務理念,為客戶提供網站制作、網站設計 網站設計制作按需制作,公司網站建設,企業(yè)網站建設,高端網站設計,成都全網營銷推廣,成都外貿網站制作,定州網站建設費用合理。
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.Discount
from Orders o,[Order Details] od, Employees e,
Products p, Suppliers s, Customers c
where (o.OrderID = od.OrderID) and
(o.EmployeeID = e.EmployeeID) and
(o.CustomerID = c.CustomerID) and
(od.ProductId = p.ProductID) and
(p.SupplierID = s.SupplierID);
網站題目:SQLServerinsert與Select組合使用的方法
URL地址:http://m.fisionsoft.com.cn/article/dpoopso.html


咨詢
建站咨詢
