超过经理收入的员工MySql语句
方法1 用where语句

select *
from employee as a, employee as b;

从两个表里使用 Select 语句可能会导致产生 笛卡尔乘积 。在这种情况下,输出会产生 4*4=16 个记录。然而我们只对雇员工资高于经理的人感兴趣。所以我们应该用 WHERE 语句加 2 个判断条件。
作者:LeetCode
链接:https://leetcode.cn/problems/employees-earning-more-than-their-managers/solutions/9579/chao-guo-jing-li-shou-ru-de-yuan-gong-by-leetcode/
select a.name as 'employee'
from employee as a, employee as b
where a.mangerid=b.id
and a.salary > b.salary;

2 连接join
select a.name as 'employee'
from employee as a join employee as b
on a.mangerid=b.id and a.salary>b.salary;
150

被折叠的 条评论
为什么被折叠?



