0
任何人都可以描述使用存儲過程中的臨時表來更新mysql中的兩個表的簡單示例嗎?在存儲過程中使用臨時表進行更新mysql
任何人都可以描述使用存儲過程中的臨時表來更新mysql中的兩個表的簡單示例嗎?在存儲過程中使用臨時表進行更新mysql
兩種臨時表可用。一個是基於會話的,另一個是全局臨時表。
下面是簡單的例子:
Select A,b,c into #MyTemp From MyDbTable
在上面的例子中,#myTemp是要創建臨時表。 MyDbTable是數據庫中存在的一個。您可以創建多個臨時表。
我建議從這裏閱讀文章:Link
--Create a temp table and insert all these counts in it
Create Table #OperatorReportCount(Id int identity,Particulars varchar(100),NoOfArticles int)
--Insert these values in table
Insert Into #OperatorReportCount(Particulars,NoOfArticles) Values('Articles processed',@ProcessedArticleCount)
Insert Into #OperatorReportCount(Particulars,NoOfArticles) Values('Articles approved',@ArticlesApproved)
Insert Into #OperatorReportCount(Particulars,NoOfArticles) Values('Articles rejected',@ArticleRejectedCount)
Insert Into #OperatorReportCount(Particulars,NoOfArticles) Values('Rejections recieved',@RejectionsRecievedCount)
Insert Into #OperatorReportCount(Particulars,NoOfArticles) Values('Articles put on hold',@ArticlesOnHoldCount)
--Select the operator count table
Select Particulars,NoOfArticles From #OperatorReportCount