2010-12-09 118 views
0

我都含有學生信息的表(姓名,身份證,當然,....),我有包含了像(ID,學生請假)信息的另一個表SQL查詢 - 加入

我需要生成的報告,這是當然,所有誰缺席....

很困惑,如何做正確的學生 - 我使用一個外連接或者是什麼原因SQL 5.0一直給我像語法錯誤的錯誤。 ...

有權使用servlet的此查詢... !!!

目前正在使用的查詢兩個部分....但不生成表正確....

+4

後您的查詢。 – 2010-12-09 16:40:09

+0

也給您的數據結構的詳細信息,尤其是數據類型,以及如何判斷一個學生是否不存在。 – JohnFx 2010-12-09 16:41:49

回答

0
SELECT * FROM Student s LEFT JOIN Attendance a ON a.student_id = s.id WHERE s.course_id = "ENG" 
0
Select * From Student s left join Attendance a on a.student_id = s.id where course_id='ENG' 
0
SELECT * 
FROM Student s, Attendance a 
WHERE s.id = a.student_id 
AND s.course_id = "ENG" 
AND s.id = <the_retrieved_id> 

應該也是可以的。

0

我建議將Student.id轉換爲Student.student_id以使其清晰,
並且還在課程表中使用整數表示鍵。 然後用加入像Pradeep Singh只能用 「使用」:


select * from Student s left join Attendance a using (student_id) where s.course_id="ENG"