This discussion is archived
2 Replies Latest reply: Feb 9, 2013 10:16 PM by jeneesh RSS

Self Join re

pawii Newbie
Currently Being Moderated
select e.last_name,e.department_id,c.last_name
from employees e join employees c
on (e.department_id=c.department_id) and e.department_id=20
/

i want to print the names of colleagues of all employees it work fine except in the case the employee itself
that it shows all colleague of fay plus fay colleague is fay and it follows for all employees
so how to remove fav colleague fay
  • 1. Re: Self Join re
    jeneesh Guru
    Currently Being Moderated
    You could try..
    select e.last_name,e.department_id,c.last_name
    from employees e join employees c
    on (
          e.department_id=c.department_id 
          --"Add the below condition"
          and e.employee_id != c.employee_id 
       ) 
    and e.department_id=20;
  • 2. Re: Self Join re
    pawii Newbie
    Currently Being Moderated
    i think it was all about syntax but man u showed me tht it was aal about intelligence :)
    thnxxx man

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points