1

在此处输入图像描述
每个Student都有Teacher自己的UNIQUE UserID
是否可以一次从三个表中检索值?这样:它将显示UserID每个人拥有的StudentTeacher?我尝试了以下查询,但它不起作用:

SELECT u.UserID, StudentID, TeacherID  
FROM User u  
INNER JOIN (SELECT * FROM Student, Teacher) ss  
ON u.UserID = ss.UserID  
4

1 回答 1

1

也许这样:

SELECT u.UserID, S.StudentID, T.TeacherID  
from User U
left join Student S on S.UserID = u.UserID  
left join Teacher T on T.UserID = U.UserID  
于 2013-07-16T07:09:12.583 回答