基于一个列表内部的比较,通常使用join on 连接的方式进行比较得到结果
例:
给定 Employee 表,编写一个 SQL 查询,该查询可以获取收入超过他们经理的员工的姓名。在上面的表格中,Joe 是唯一一个收入超过他的经理的员工。
select E1.name as Employee
from Employee E1
join Employee E2
on E2.Id=E1.ManagerId
where E1.salary>E2.salary;
select E1.name as Employee
from
Employee as E1,
Employee as E2
where
E2.Id=E1.ManagerId
And
E1.salary>E2.salary;
在上一篇文章中温度的比较也属于表内部的比较。