200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > 用子查询的方法查找研发部比财务部所有雇员收入都高的雇员的姓名

用子查询的方法查找研发部比财务部所有雇员收入都高的雇员的姓名

时间:2021-10-23 10:18:30

相关推荐

用子查询的方法查找研发部比财务部所有雇员收入都高的雇员的姓名

第一遍:

mysql> select 姓名 from employees-> where 编号 =-> (select 编号 from employees-> where 收入 =-> select 收入 -> from salary-> where 编号 = '4')-> and 收入 > max(收入 =-> select 收入-> from salary-> where 编号 = 1);

意识到子循环中括号没有加全。

第二遍:

mysql> select 姓名 from employees-> where 编号 =-> (select 编号 from employees-> where 收入 =-> (select 收入 -> from salary-> where 编号 = '4')-> and 收入 > max(收入 =-> (select 收入-> from salary-> where 编号 = 1)));1054 - Unknown column '收入' in 'where clause'

查询输入的表格错误,将employees 改为salary

第三遍:

mysql> select 姓名 from employees-> where 编号 =-> (select 编号 from salary-> where 收入 =-> (select 收入 -> from salary-> where 编号 = '4')-> and 收入 > max(收入 =-> (select 收入-> from salary-> where 编号 = 1)));1111 - Invalid use of group function```sql

函数使用无效(回课本敲例题了,敲完再来)

mysql> select 姓名 from employees as e,departments as d,salary as a-> where 收入 > all-> (select 收入 from employees as e,departments as d,salary as s-> where e.部门号 = d.部门号 and s.编号 = e.编号 and d.部门名称 = '财务部')-> and e.部门号 = d.部门号 and a.编号 = e.编号 and d. 部门名称 = '研发部';

over

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。