mysql-sql-第十四周

学习目标:

sql

学习内容:

40.查询学过「哈哈」老师授课的同学的信息

Select * from students left join score on students.stunm=score.stunm where counm = (select counm from teacher left join course on teacher.teanm=course.teanm where teacher.name= '哈哈');

出现错误

ERROR 1241 (21000): Operand should contain 1 column(s)

是MySQL数据库中的一个常见错误。这个错误发生的原因通常是在你尝试在期望一个列值的地方使用了一个返回多列的子查询或者函数。

修改后

Select * from students left join score on students.stunm=score.stunm where counm = (select counm from teacher left join course on teacher.teanm=course.teanm where teacher.name= '哈哈');

出现错误

ERROR 1242 (21000): Subquery returns more than 1 row

*这个错误发生在SQL查询中,当子查询返回多于一行结果时,而父查询期望子查询返回单行结果时就会出现这个错误。在SQL中,子查询通常用在WHERE或SELECT列表中,并期望返回一个标量值(单个值)

换一种方式

select students.* from students,teacher,course,score

where students.stunm = score.stunm and course.counm=score.counm and course.teanm = teacher.teanm and teacher.name = '哈哈';

学习时间:

1月-3月,每天一小时左右

学习产出:

一周一发

相关推荐
小咖张6 分钟前
spring声明式事务,finally 中return对事务回滚的影响
数据库·java 声明式事务
JSON_L7 分钟前
MySQL 加锁与解锁函数
数据库·mysql
白鲸开源1 小时前
收藏!史上最全 Apache SeaTunnel Source 连接器盘点 (2025版),一篇通晓数据集成生态
大数据·数据库·开源
MonKingWD1 小时前
MySQL事务篇-事务概念、并发事务问题、隔离级别
数据库·后端·mysql
Java水解2 小时前
深入理解 SQL 中的 COALESCE、NULLIF 和 IFNULL 函数
后端·sql
我科绝伦(Huanhuan Zhou)2 小时前
银河麒麟V10一键安装Oracle 11g脚本分享
数据库·oracle
秋千码途3 小时前
一道同分排名的SQL题
数据库·sql
似水流年流不尽思念5 小时前
MySQL 的 MVCC 到底解决了幻读问题没有?请举例说明。
mysql·面试
秋难降5 小时前
零基础学SQL(八)——事务
数据库·sql·mysql
Starry_hello world5 小时前
MySql 表的约束
数据库·笔记·mysql·有问必答