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

学习产出:

一周一发

相关推荐
一只大黄猫3 小时前
【数据库-入门2】基本概念
数据库
实泽有之,无泽虚之4 小时前
MySQL主机因多次连接数据库错误而被阻塞
数据库·sql·mysql
Knight_AL5 小时前
从自然语言到 SQL:为什么向量数据库是更好的选择
数据库·sql
Maybe I Simple6 小时前
MySql 数据库分表 简单思路
数据库·php·webman
智航GIS6 小时前
8.11 sys 模块
数据库·windows·microsoft
陈天伟教授6 小时前
国产数据库快速入门《数据库技术原理及应用》(DM8)
数据库·数据挖掘
optimistic_chen6 小时前
【Redis 系列】常用数据结构---SET类型
linux·数据结构·数据库·redis·set·数据类型·命令行
zbguolei7 小时前
上传 Excel 文件进行数据库比对--增加导出功能
数据库·excel
amao99887 小时前
数据库原理与技术 - 3-7 视图和索引 View& Index
数据库·sql·oracle
酸菜牛肉汤面7 小时前
30、大表数据查询,怎么优化
数据库