在存储过程mysql中使用临时表进行更新

时间:2012-12-26 06:15:08

标签: asp.net mysql asp.net-mvc c#-4.0

是否可以描述一个在存储过程中使用临时表来更新mysql中的两个表的简单示例?

2 个答案:

答案 0 :(得分:0)

有两种临时表可用。一个是基于会话的,另一个是全局临时表。

下面是一个简单的例子:

    Select A,b,c into #MyTemp From MyDbTable

在上面的示例中,#myTemp是您正在创建的临时表。 MyDbTable是数据库中存在的。您可以创建多个临时表。

我建议您从这里阅读文章:Link

答案 1 :(得分:0)

 --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
相关问题