谁不学习谁是狗 2021-12-30 13:46 采纳率: 83.3%
浏览 31
已结题

明明应该有两个结果,但是为什么只出来一个

从course中找到课程名并记录课程号,再根据课程号从sc中找到学习的人的学号(两个)最后从student中根据学号找到所有信息(Transact-SQl语句没有错误,能出来一个结果,但是另一个结果出不来)
declare @c_name char(20),@c_no char(6),@s_no char(12);
select @c_no=c_no from course
where c_name='c语言';
select @s_no=s_no from sc
where c_no=@c_no;
select * from student where s_no=@s_no;

  • 写回答

1条回答 默认 最新

  • bekote 2021-12-30 16:34
    关注
    
    declare @c_no char(6);
    select @c_no=c_no from course
    where c_name='c语言';
    select student.* from sc join student on sc.s_no=student.s_no
    where sc.c_no=@c_no;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 1月8日
  • 已采纳回答 12月31日
  • 修改了问题 12月30日
  • 创建了问题 12月30日