A学过001课程的sno集合select sno from SC where cno001;B学过002课程的sno集合select sno from SC where cno002;select sno,sname from Student where sno in A and B;————SQL 错误 [1242] [21000]: Subquery returns more than 1 row 问题分析你的报错信息是SQL 错误 [1242] [21000]: Subquery returns more than 1 row这是因为and后面直接写了(select s_no from SC where c_noc002)这个子查询会返回多行数据但它没有跟任何比较 / 匹配条件导致语法逻辑错误。你的目标是查询同时选了 c001 和 c002 两门课的学生姓名和学号而当前写法无法实现 “同时选两门课” 的逻辑。✅ 修正方案3 种常用写法写法 1两次in子查询最易理解sqlselect s_no, sname from Student where s_no in (select s_no from SC where c_no c001) and s_no in (select s_no from SC where c_no c002);写法 2inner join自连接sqlselect distinct s1.s_no, s.sname from SC s1 join SC s2 on s1.s_no s2.s_no join Student s on s.s_no s1.s_no where s1.c_no c001 and s2.c_no c002;写法 3group by having适合多课程扩展sqlselect s.s_no, s.sname from SC sc join Student s on sc.s_no s.s_no where sc.c_no in (c001, c002) group by sc.s_no, s.sname having count(distinct sc.c_no) 2; 关键说明原错误的核心and后面的子查询必须跟列名关联比如s_no in (...)否则数据库无法判断如何使用这个多行结果。三个写法的效果完全一致都能找出同时选了两门课的学生写法 1 适合初学者逻辑清晰写法 2 性能较好适合数据量大的场景写法 3 在扩展到 “同时选 3 门 / 更多课程” 时最方便只需改in列表和count即可。