开发者

problem with sql syntax

开发者 https://www.devze.com 2023-01-27 12:15 出处:网络
The sql syntax is follo开发者_如何转开发wing: SELECT y.NAME, y.EMAIL, k.DATE, k.WORK_NR, k.SCORE, k.FILENAME

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';
0

精彩评论

暂无评论...
验证码 换一张
取 消