有两个表 student(stu_id,stu_name...) 和grade(stu_id1,stu_id2,grade_value)
其中student是学生信息
grade是学生间互相评分的分数信息:stu_id2 给stu_id1评的分数为grade_value现在要写一个sql语句 查询stu_id=1的学生所得到的所有评分和评分人,
要求是 即使还未给他评分的同学 也出现在结果中 所评分数为空
所以应该是用什么left join之类的
其中student是学生信息
grade是学生间互相评分的分数信息:stu_id2 给stu_id1评的分数为grade_value现在要写一个sql语句 查询stu_id=1的学生所得到的所有评分和评分人,
要求是 即使还未给他评分的同学 也出现在结果中 所评分数为空
所以应该是用什么left join之类的
from student a left join (select * from grade where stu_id1=1) b on a.stu_id=b.stu_id2
from student a left join grade B on a.stu_id=b.stu_id2
where b.stu_id1=1
from student a left join grade b on a.stu_id=b.stu_id2
where b.stu_id=1
select a.stu_id,a.stu_name,b.grade_value
from student a left join grade B on a.stu_id=b.stu_id2
where b.stu_id1=1) b1 on a1.stu_id=b1.stu_id