CREATE PROCEDURE mysp
@id int
ASdeclare @t table(myid int,myname varchar(50),pid int)
insert @t select * from test1 where pid=@id
while(@@rowcount>0)
begin
insert @t select a.* from test1 a,@t b where a.pid=b.myid
end
select * from @t
return
GO
数据库结构为 id int ,name varchar(50),pid int;分别代表编号,名称,父编号
@id int
ASdeclare @t table(myid int,myname varchar(50),pid int)
insert @t select * from test1 where pid=@id
while(@@rowcount>0)
begin
insert @t select a.* from test1 a,@t b where a.pid=b.myid
end
select * from @t
return
GO
数据库结构为 id int ,name varchar(50),pid int;分别代表编号,名称,父编号
如下这部分什么意思
while(@@rowcount>0)
begin
insert @t select a.* from test1 a,@t b where a.pid=b.myid
end
--->
Set @total = @@rowcount
while(@total >0)
Begin
Set @total = @total - 1
End