1St表(学生)
|name | matricNo | Subject |
|John | A01 | History |
|John | A01 | Math |
|John | A01 | Language |
2Nd表(备注)
|name | matricNo | Subject | Grade |
|John | A01 | History | A |
|John | A01 | Math | B |
我已经进行了查询 * 所以像这样的输出 *
查询=从学生选择a。*,b.grade左边的加入备注b(a.matricNo = b.matricNo)
|name | matricNo | Subject | Grade |
|John | A01 | History | A |
|John | A01 | Math | B |
但我希望输出如下: -
|name | matricNo | Subject | Grade |
|John | A01 | History | A |
|John | A01 | Math | B |
|John | A01 | Language | NULL |
我已尝试左连接,右连接也给我相同的输出。
答案 0 :(得分:0)
您可以加入表格学生中的所有列,如下所示
select t1.*,t2.grade from student t1
left join remark t2 on t1.name =t2.name and t1.matricno=t2.matricno and t1.subject =t2.subject
这有效Fiddle