2 Replies Latest reply: Feb 10, 2013 12:16 AM by jeneesh RSS

    Self Join re

    pawii
      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
          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
            i think it was all about syntax but man u showed me tht it was aal about intelligence :)
            thnxxx man