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

学习产出:

一周一发

相关推荐
笨蛋不要掉眼泪26 分钟前
Nacos配置中心详解:核心用法、动态刷新与经典面试题解析
java·数据库·后端
@@神农29 分钟前
PostgreSQL-SQL语句的执行过程(一)
数据库·sql·postgresql
Andy Dennis2 小时前
一文漫谈数据库存储之索引(B+, B-link, LSM tree等)
数据库·b+树·lsm-tree
CHANG_THE_WORLD2 小时前
字符串定义的汇编分析
汇编·数据库
数据知道2 小时前
PostgreSQL:如何通过progres_fdw跨库关联查询?
数据库·postgresql
v***57002 小时前
MYSQL 创建索引
数据库·mysql
heimeiyingwang3 小时前
大模型 RAG 技术原理与企业级落地实践
大数据·数据库·人工智能·架构
倔强的石头_4 小时前
【金仓数据库】ksql 指南(七) —— 启动和管理事务(KingbaseES 数据一致性保障)
数据库
计算机毕设vx_bysj68695 小时前
计算机毕业设计必看必学~基于SpringBoot校园招聘系统的设计与实现,原创定制程序、单片机、java、PHP、Python、小程序、文案全套、毕设成品等!
java·spring boot·mysql·课程设计
志栋智能5 小时前
自动化运维真的只能选复杂平台吗?
运维·网络·数据库·人工智能·自动化