select Sname,Student.Sno
from Student --从学生表中查询姓名、学号
left join SC on SC.Sno=Student.Sno --通过课程号左连接选修表
left join Course on SC.Cno=Course.Cno--通过课程号左连接课程表
where Student.Sno not in(select Sno from SC where Cno=(select Cno from Course where Cname='数据库')) --选择没有学习数据库的学生
group by Sname,Student.Sno--按姓名、学号分组