我有两张桌子:
grades
(id,subject_code,subject_description,midterm,final,final_remarks)
scholars
(身份证,身份证号码,姓氏,名字,中间名,学校,年份,学期,课程,行动)
我如何加入他们?
我想从成绩中获取subject_code,subject_description,midterm,final和final_remarks,以及学者的全名?
答案 0 :(得分:0)
需要一个列到学者表的grade_id字段,该字段对表格的成绩进行评分。
SELECT DISTINCT gr.subject_code, gr.subject_description, gr.midterm, gr.final, gr.final_remarks, sl.fullname
FROM grades gr
LEFT JOIN scholars sl ON (gr.ID = sl.grades_id)
WHERE 1=1
答案 1 :(得分:0)
这是你的问题的解决方案 -
SELECT grades.subject_code , grades.subject_description , grades.final , grades.final_remarks , scholars.fullname
from grades
join scholars ON grades.lastname = scholars.lastname ;