Mysql说:#1242 - 子查询返回超过1行 [英] Mysql said: #1242 - subquery returns more than 1 row
问题描述
SELECT student.name,course.name,result.cijfer,(SELECT AVG(cijfer)FROM result GROUP BY result.student_id)AS Gemiddelde FROM course
JOIN test ON course.id = test .course_id
JOIN结果ON test.id = result.test_id
JOIN student ON result.student_id = student.id
订购学生。名称;
#1242是什么 - 子查询返回超过1行意味着什么?
我尝试过的事情:
i无法弄明白#1242 - 子查询返回超过1行的意思。我正在研究学校项目
SELECT student.name, course.name, result.cijfer, (SELECT AVG(cijfer) FROM result GROUP BY result.student_id)AS Gemiddelde FROM course
JOIN test ON course.id = test.course_id
JOIN result ON test.id = result.test_id
JOIN student ON result.student_id = student.id
ORDER BY student.name;
what does #1242 - Subquery returns more than 1 row mean?
What I have tried:
i cant figure it out what #1242 - Subquery returns more than 1 row means. i am working on a school project
推荐答案
这是由于子查询字段。你不能有多个结果。您的子查询有一个分组依据,它为结果中找到的每个学生返回一个AVG。
This is due to the sub-query field. You cannot have more than one result. Your sub-query has a "Group by" that returns an AVG for each student found in result.
从您的问题来看,我的理解是您试图获得每个学生的平均结果。
如果是,请将where by替换为where where条件。
From your question,my understanding is you are trying to get average results for each student.
If so,replace Group by with where condition.
这篇关于Mysql说:#1242 - 子查询返回超过1行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!