problem with sql syntax
The sql syntax is follo开发者_如何转开发wing:
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';
But I get some errors, any Ideas?
You're using WHERE twice
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';
change to this
Don't you need join statements? E.g.,
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';
精彩评论