如何从表中删除第二高的薪水

时间:2019-06-26 19:29:28

标签: mysql

我正在尝试从表格中删除员工第二高的薪水,但是我找不到正确的答案。

delete FROM user 
where salary =(select max(salary) from user where salary<(select max(salary) from user));

1 个答案:

答案 0 :(得分:0)

将子查询嵌套到另一个查询中:

delete FROM user 
where salary = (select t.sal from (
    select max(salary) sal from user where salary < (select max(salary) from user)
  ) t
);