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

学习产出:

一周一发

相关推荐
可涵不会debug37 分钟前
【IoTDB】时序数据库选型指南:工业大数据场景下的技术突围
数据库·时序数据库
ByteBlossom40 分钟前
MySQL 面试场景题之如何处理 BLOB 和CLOB 数据类型?
数据库·mysql·面试
玉衡子42 分钟前
九、MySQL配置参数优化总结
java·mysql
麦兜*1 小时前
MongoDB Atlas 云数据库实战:从零搭建全球多节点集群
java·数据库·spring boot·mongodb·spring·spring cloud
Slaughter信仰1 小时前
深入理解Java虚拟机:JVM高级特性与最佳实践(第3版)第十章知识点问答(10题)
java·jvm·数据库
麦兜*1 小时前
MongoDB 在物联网(IoT)中的应用:海量时序数据处理方案
java·数据库·spring boot·物联网·mongodb·spring
-Xie-1 小时前
Mysql杂志(十六)——缓存池
数据库·mysql·缓存
玉衡子1 小时前
八、MySQL全局优化总结&MySQL8新特性
java·mysql
七夜zippoe1 小时前
缓存与数据库一致性实战手册:从故障修复到架构演进
数据库·缓存·架构