select sno,sname,age,address from stu01 where sno=(select sno from sco01 where cno=1002)
报错:Subquery returns more than 1 row
这个错误是:子查询返回了多行数据,=后的语句返回数据超过一个,导致不对应
1)在子查询条件语句加limit 1,找到一个符合条件的就可以了
select sno,sname,age,address from stu01 where sno=(select sno from sco01 where cno=1002 limit 1) ;
2)在子查询前加any关键字
select sno,sname,age,address from stu01 where sno = any(select sno from sco01 where cno=1002) ;
3)在子查询前加in关键字
select sno,sname,age,address from stu01 where sno in (select sno from sco01 where cno=1002) ;