从第二张表中选择最高薪水记录(加入表>> MySQL)

时间:2020-08-16 19:31:03

标签: mysql

为成为菜鸟而道歉。。看起来很简单,但现在还停留在这里

table emp

e_id | empname
1    abc
2    xyz
3    PQR
4    def

table sal

s_id | empsal
1    2000
2    1000
3    1000
4    2000

期望的op是具有最高sal的emp名称

abc
def

尝试过

select e.empname from emp e
inner join sal s
on e.e_id = s.s_id
where (s.empsal) in
(select max(empsal) from sal group by id);

0 个答案:

没有答案
相关问题