这里有一个单位表 unitT
Idname1单位12单位2
有一个评分项目表 itemT
Idname1项目12项目2
有一个单位得分表 scoreT
IdunitIditemidscore11120221503123042260
现在需要遍历所有单位将他们的分数查询出来,就用循环遍历的方法
当前我使用的是游标方法,还有其他遍历方式。
declare @
a nvarchar(
40);
declare mycursor cursor
for select id
from unitT
open mycursor
fetch next
from mycursor
into @
a
while (@@fetch_status=
0)
begin
select *
from scoreT where unitId=@
a
fetch next
from mycursor
into @
end--遍历结构结束
close mycursor
deallocate mycursor
转载请注明原文地址: https://ju.6miu.com/read-968731.html