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月,每天一小时左右

学习产出:

一周一发

相关推荐
苦瓜炒蛋挞4 分钟前
小迪安全第二十二天-安全开发-PHP应用&数据库操作&留言板功能&第三方插件
数据库·网络安全·php·小迪安全
chushiyunen17 分钟前
redis命令 geo(对地理坐标的支持)
数据库·redis·缓存
baivfhpwxf202322 分钟前
删除数据表SQL,不是删除数据,是删除表结构
数据库·sql
码界奇点1 小时前
深入解析MySQL6存储过程游标与触发器的实战应用与性能优化
数据库·sql·性能优化·七牛云存储
数据知道1 小时前
FastAPI项目:从零到一搭建一个网站导航系统
python·mysql·fastapi·python web·python项目
鸽鸽程序猿1 小时前
【Redis】List类型介绍
数据库·redis·list
帅中的小灰灰1 小时前
C++编程观察者设计模式
数据库·c++·设计模式
2501_941664961 小时前
云计算与边缘计算:新时代数字化转型的双轮驱动
数据库
x***58701 小时前
GitHub星标10万+的Redis项目,使用教程
数据库·redis·github
Leon-Ning Liu2 小时前
MySQL 5.7大表索引优化实战:108GB数据建索引效率提升50%
运维·数据库·mysql