2010-11-30 76 views
0

的SQL語法如下:問題SQL語法

SELECT y.NAME, y.EMAIL, k.DATE, k.WORK_NR, k.SCORE, k.FILENAME 
FROM bas1.students y, bas1.assignments k, bas1.topics a 
WHERE y.ID = k.student_id AND k.topic_id = a.id 
WHERE a.NAME = 'History'; 

,但我得到了一些錯誤,任何想法?

+1

並且錯誤是? – Breezer 2010-11-30 21:45:29

回答

8

您使用WHERE兩次

SELECT y.NAME, y.EMAIL, k.DATE, k.WORK_NR, k.SCORE, k.FILENAME 
FROM bas1.students y, bas1.assignments k, bas1.topics a 
WHERE y.ID = k.student_id AND k.topic_id = a.id 
AND a.NAME = 'History'; 

改變這種

0

你不需要加入語句?例如,

SELECT y.NAME, y.EMAIL, k.DATE, k.WORK_NR, k.SCORE, k.FILENAME 
FROM bas1.students y JOIN bas1.assignments k ON y.ID = k.student_id 
JOIN bas1.topics a ON k.topic_id = a.id 
WHERE a.NAME = 'History';