2013-07-16 58 views
1

enter image description here
每個StudentTeacher有自己UNIQUEUserID
是否有可能在一次檢索來自三個表中的值? 這樣:它會顯示UserID擁有的每個StudentTeacher? 我試過下面的查詢,但它不工作:檢索值

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

回答

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 
+0

加入,我看到的。謝謝 –