我有两张这样的表:
subject_descriptors descriptor_id,subject_id,成绩,描述符
,其数据行如下:
1, 5, p2, some text
2, 5, p3, some more text
和
subject_list subject_id,subject
包含这样的数据行
5, science
6, french
因此您可以看到主题可以有不同的成绩/文本
我想创建一个查询,它给了我:
主题,成绩,描述符
类似的东西:
science, p2, some text
science, p3, some more text
我尝试过各种各样的连接失败:
SELECT subject_list.subject, subject_descriptors.grades
FROM subject_list, subject_descriptors
WHERE subject_list.subject_id = subject_descriptors.subject_id
我知道这是错的,但我无法理解它。有什么帮助吗?
答案 0 :(得分:0)
试试这个:
SELECT sl.subject, sd.grades, sd.descriptor
FROM subject_descriptors sd
INNER JOIN subject_list sl ON sd.subject_id = sl.subject_id