列出薪水与姓名ram或sham相同的员工

时间:2019-11-11 06:09:21

标签: sql

列出employees的薪水与“ ram”或​​“ sham”的薪水相同。

以下是表格的详细信息:

emp_id, emp_name, job_name, salary

这是我的查询:

select * 
from employees 
where salary = (select salary 
                  from employees
                 where emp_name ='sham' or emp_name = 'ram');

1 个答案:

答案 0 :(得分:3)

select * 
from employees 
where salary IN 
(
  select salary  
  from employees 
  where emp_name IN ('sham', 'ram')
);