[42000][40000] Error while compiling statement: FAILED: SemanticException Line 0:-1 Unsupported SubQuery Expression ''语文'': Nested SubQuery expressions are not supported.
遇到的错误信息 [42000][40000] Error while compiling statement: FAILED: SemanticException Line 0:-1 Unsupported SubQuery Expression ''语文'': Nested SubQuery expressions are not supported.
表明所使用的数据库系统或查询引擎不支持嵌套子查询,或者在特定上下文中不支持这样的表达式。
原SQL:
-- 2. 查询一共参加三门课程且其中一门为语文课程的学生的id和姓名
select
t1.stu_id,
stu_name
from student_info t1
join
(
select stu_id,
count(score_info.course_id) cc
from score_info
where stu_id in (select stu_id
from score_info
where course_id = (select course_id from course_info where course_name = '语文'))
group by stu_id
having cc = 3
) t2
on
t1.stu_id = t2.stu_id;
正确运行SQL:
-- 2. 查询一共参加三门课程且其中一门为语文课程的学生的id和姓名
select
t1.stu_id,
stu_name
from student_info t1
join
(
select stu_id,
count(*) cc
from score_info
where stu_id in (select stu_id
from score_info
where course_id = (select course_id from course_info where course_name = '语文'))
group by stu_id
having cc = 3
) t2
on
t1.stu_id = t2.stu_id;
其中区别仅在:
结果: