4_2.sql

来自「to become acquainted with a concept &#17」· SQL 代码 · 共 38 行

SQL
38
字号
if (cursor_status('global', 'cursor_1')<>-3)
deallocate  global cursor_1

declare cursor_1 cursor
global
scroll
keyset
for select t2.id_stud as ID
from Student t2
INNER JOIN Mark t4 
ON t2.id_stud=t4.id_stud
INNER JOIN Mark_names t5 
ON t4.id_mark=t5.id_mark
where ball_name<=2

declare @var int, @featch_res int

open cursor_1
while(1=1)
begin
	


	fetch next from cursor_1 into @var
	select st_surname as LName, left(st_name,1) as FName, left(st_pname,1) as Mname, group_name as Groupp 
	from Person t1 
	INNER JOIN Student t2  
	ON t1.id_person=t2.id_person 
	INNER JOIN Grouppa t3  
	ON t2.id_group=t3.id_group 
	where id_stud=@var

set @featch_res=@@FETCH_STATUS	
if (@featch_res=-1)
	break;

end
close cursor_1

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?