Home > Database > Mysql Tutorial > 利用存储过程_MySQL

利用存储过程_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 13:55:06
Original
791 people have browsed it

利用存储过程来消除数据库中冗余的数据
CREATE PROCEDURE sp_mytest AS
declare @pro varchar(50)
declare @mm int
declare wu Cursor for select distinct product from mytest


open wu
fetch next from wu into @pro
while @@fetch_status=0
begin
select @mm=sum([cost]) from mytest where [product]=@pro
delete from mytest where [product]=@pro
insert into mytest ([product],[cost]) values(@pro,@mm)

fetch next from wu into @pro
end
close wu
deallocate wu
GO
我们可以使用作业进行相应的数据的更新

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template