Home » SQL & PL/SQL » SQL & PL/SQL » Self join
Self join [message #600] Sun, 24 February 2002 19:21 Go to next message
Sambit Satpathy
Messages: 1
Registered: February 2002
Junior Member
Hi,
Do we need to perform a self-join on any table for any purpose,if it has already a primary key defined in it?
Can somebody clarify this with an example please?
Re: Self join [message #608 is a reply to message #600] Mon, 25 February 2002 00:17 Go to previous messageGo to next message
pratap kumar tripathy
Messages: 660
Registered: January 2002
Senior Member
here is an example

select e1.ename employee, e2.ename manager
from emp e1, emp e2
where e2.empno=e1.mgr
/
Re: Self join [message #614 is a reply to message #600] Mon, 25 February 2002 00:41 Go to previous message
pratap kumar tripathy
Messages: 660
Registered: January 2002
Senior Member
Q:-in your example,what is the primary key?
A:-in my query empno is primary key.

Q:-actually what i neded to ask is do we need to use self join for anything if we've defied primary key in a table?

A:-not necessarily, it depend on your requirement. see my query it returns the employee name and the manager's name of that employee and a both of the information in emp table so we have to perform self join.

Q:-r u from orissa?
A:-yes i am , see www.geocities.com/pktripathy fro details
Previous Topic: How can I find the last_updated row in a table?
Next Topic: Group function count
Goto Forum:
  


Current Time: Fri Sep 17 11:46:44 CDT 2021