How to find the same salaries and department names?
This should work:

select e1.* 
  from employees e1 inner join (
    select count(employee_id) as CNT, department_id, salary 
    from employees group by departmant_id, salary) t1 
  on e1.department_id=t1.department_id and e1.salary=t1.salary 
  where t1.CNT&gt;1


The problem with your own query is twofold:


the return value of (select...from ..e2..) is from the very nature of your problem not unique, so the "=" relationship should either throw an error or return whichever is the first result (I'm not familiar enough with MySQL to know which applies), which doesn't have to be the one you're looking for.
filtering via "e1.employee_id =" will only ever be true for the record itself, but NOT for another record that matches your criteria


If you insist on using a filter:

SELECT * FROM employees e1
WHERE (e1.department_id,e1.salary) IN 
 (SELECT e2.department_id,e2.salary
  FROM employees e2
  WHERE e2.employee_id &lt;&gt; e1.employee_id)