728x90
select e.Name as Employee
from Employee as e join Employee as m on m.Id = e.ManagerId
where e.Salary > m.Salary
위 코드에서 e는 Joe, Henry 만 남아있고(join의 결과 managerID == ID)
m은 Sam, Max만 존재하는 것이다.
self join
www.w3schools.com/sql/sql_join_self.asp
728x90
'SQL' 카테고리의 다른 글
[LeetCode] Delete Duplicate Emails (delete, self join, and) (0) | 2021.04.09 |
---|---|
[LeetCode] Customes Who Never Order (is null, join) (0) | 2021.04.09 |
[LeetCode] Duplicate Emails (group by, having) (0) | 2021.04.09 |
[LeetCode] Second Highest Salary MySQL (0) | 2021.04.08 |
[MySQL] Code Snippets (0) | 2021.04.08 |
댓글