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

学习产出:

一周一发

相关推荐
jason成都7 小时前
实战 | 国产数据库 R2DBC-JDBC 桥接踩坑记 - JetLinks适配达梦数据库
java·数据库·物联网
田超凡7 小时前
深入理解MySQL_6 Temporary临时表
mysql·java-ee
Elastic 中国社区官方博客7 小时前
使用 Elasticsearch 管理 agentic 记忆
大数据·数据库·人工智能·elasticsearch·搜索引擎·ai·全文检索
小宇的天下7 小时前
Calibre 3Dstack --每日一个命令day13【enclosure】(3-13)
服务器·前端·数据库
云和数据.ChenGuang7 小时前
达梦数据库安装服务故障四
linux·服务器·数据库·达梦数据库·达梦数据
尽兴-8 小时前
MySQL 8.0主从复制原理与实战深度解析
数据库·mysql·主从复制
Mr_sun.8 小时前
Day04——权限认证-基础
android·服务器·数据库
百锦再8 小时前
国产数据库现状与技术演进
数据库·python·plotly·flask·virtualenv·pygame·tornado
煎蛋学姐8 小时前
SSM学生会综合管理系统8berj(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面
数据库·计算机毕业设计·ssm 框架·学生会综合管理系统
YongCheng_Liang8 小时前
MySQL 高级特性深度解析:从索引优化到高可用架构
运维·数据库·mysql