欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

181. 超过经理收入的员工(MySQL)(自连接)

程序员文章站 2022-06-10 23:34:44
...

1 题目

181. 超过经理收入的员工(MySQL)(自连接)

2 MySQL

2.1 方法一(A join B on 条件)

select A.Name as Employee
from Employee as A join Employee as B
    on A.ManagerId = B.Id
    and A.Salary > B.Salary;

2.2 方法二(A, B where 条件)

select A.Name as Employee
from Employee as A, Employee as B
where A.ManagerId = B.Id
    and A.Salary > B.Salary;

3 总结

join的两种等价写法
一个表可以和自身进行连接,即自连接
相关标签: MySQL