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

学习产出:

一周一发

相关推荐
DKPT几秒前
正则表达式
java·数据库·笔记·学习·正则表达式
CodeJourney.2 分钟前
DeepSeek与WPS的动态数据可视化图表构建
数据库·人工智能·信息可视化
背着黄油面包的猫16 分钟前
速通FlinkCDC3.0
数据库·mysql·flink
星迹日23 分钟前
MySQL:数据库设计
数据库·mysql
听闻风很好吃39 分钟前
Redis高级数据类型解析(二)——Set、Sorted Set与Geo实战指南
数据库·redis·缓存
小刘同学++40 分钟前
Qt 使用 MySQL 数据库的基本方法
数据库·qt·mysql
编程在手天下我有1 小时前
缓存与数据库数据一致性:旁路缓存、读写穿透和异步写入模式解析
数据库·缓存·oracle·软件开发·架构设计·数据一致性
络71 小时前
IDEA导入并启动若依项目步骤(SpringBoot+Vue3)
java·spring boot·mysql·vue·intellij-idea
云攀登者-望正茂1 小时前
Redis 及其在系统设计中的作用
数据库·redis·缓存
ghostmen1 小时前
Centos 实现 MySql 8.0.40 主从配置
linux·mysql·mysql主从