具有多个内部联接的SQL查询

时间:2013-12-01 20:41:20

标签: mysql sql join

到目前为止工作

SELECT subject_en_name FROM subjects 
INNER JOIN teachers_subjects 
  ON subjects.subject_id = teachers_subjects.subject_id 
WHERE teachers_subjects.teacher_user_id = 6

这让我的主题名称很好。但是,我想不选择teachers_subjects.teacher_user_id,而是选择users_teachers.user_id。

我尝试过类似的事情:

SELECT subject_en_name FROM subjects 
INNER JOIN teachers_subjects 
  ON subjects.subject_id = teachers_subjects.subject_id 
INNER JOIN users_teachers 
  ON teachers_subjects.teacher_user_id = users_teachers.user_id 
WHERE users_teachers.user_id = 98

但是当我这样做时,它不会返回任何结果,它应返回2行

由于

0 个答案:

没有答案