自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

SQL Server insert與Select組合使用的方法

數(shù)據(jù)庫 SQL Server
在SQL Server中,insert語句和Select語句是可以組合使用的,下面就將為您具體介紹該方法,希望對您學(xué)習(xí)SQL Server insert與Select的語句能有所啟迪。

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

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

下面的語句從Orders,Order Details, Employees,Products, Suppliers, Customers表選擇相應(yīng)的

數(shù)據(jù)插入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);

 

 

【編輯推薦】

教您如何使用SQL中的函數(shù)替代游標(biāo)

SQL中的分析函數(shù)

創(chuàng)建SQL函數(shù)的實(shí)例

SQL中循環(huán)語句的效果實(shí)例

SQL中類似For循環(huán)處理的實(shí)例

責(zé)任編輯:段燃 來源: 賽迪網(wǎng)
相關(guān)推薦

2010-09-03 15:27:02

SQLSELECT語句

2010-09-13 10:43:22

SQL Server

2010-11-11 11:37:22

SQL SELECT語

2011-08-01 22:41:49

SQL Server數(shù)Insert

2010-11-11 10:18:59

select into

2010-09-06 09:36:51

SQL語句

2011-07-22 16:59:30

MySQL數(shù)據(jù)庫嵌套查詢

2010-11-09 15:06:52

SQL Server動(dòng)

2010-09-07 13:50:41

SQL語句

2010-07-02 14:52:21

SQL Server元

2010-07-14 15:22:48

SQL Server

2010-07-15 09:14:32

SQL server組

2010-07-02 13:18:01

SQL Server

2010-09-16 09:49:38

sql server建

2010-10-20 11:07:21

sql server全

2010-10-19 14:11:20

SQL SERVER恢

2010-09-10 11:01:09

sql變量

2011-07-01 13:39:28

SQL ServerInsert

2010-11-10 15:36:44

SQL Server存

2010-09-06 09:53:41

SQL Server語句
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)