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

学习产出:

一周一发

相关推荐
talenteddriver12 分钟前
mysql: MySQL索引和排序相关名词概念汇总
数据库·mysql
武昌库里写JAVA14 分钟前
iview-CRUD模板
vue.js·spring boot·sql·layui·课程设计
6极地诈唬30 分钟前
【PG漫步】DELETE不会改变本地文件的大小,VACUUM也不会
linux·服务器·数据库
MZWeiei1 小时前
Redis持久化机制中的 AOF机制简单介绍
数据库·redis
Elastic 中国社区官方博客2 小时前
Elasticsearch:在 X-mas 吃一些更健康的东西
android·大数据·数据库·人工智能·elasticsearch·搜索引擎·全文检索
酷柚易汛2 小时前
酷柚易汛ERP 2025-12-26系统升级日志
java·前端·数据库·php
wang6021252183 小时前
阿里云存储的一些简要概述
数据库·阿里云·fastapi
小徐Chao努力3 小时前
【Langchain4j-Java AI开发】08-向量嵌入与向量数据库
java·数据库·人工智能
TG:@yunlaoda360 云老大4 小时前
华为云国际站代理商GSL主要有什么作用呢?
网络·数据库·华为云
TG:@yunlaoda360 云老大4 小时前
华为云国际站代理商GSL的流量用量与资费合规是如何实现的?
网络·数据库·华为云