Questionsforum
what is self join?

what is self join?



On 2014-06-09 03:03:17.0
amrendra


Joining a table to itself is known as self join. When we have to fetch the result by comparing two columns in a single table than we have to go for self join.


On 2014-06-09 03:29:04.0
hablu
A table can be joined to itself is a self-join.


On 2014-06-09 06:58:46.0
sujata
SELECT a.column_name, b.column_name... FROM table1 a, table1 b WHERE a.common_filed = b.common_field.


On 2014-06-09 06:59:37.0
sujata
I am giving you a scenario where self join is used.
suppose that you have select an employee record whose id=107 than your query should be like this
select * from employee where id=107;
Now suppose you have to select the employee record whose id's are equals to cid.
So here you have to use join because you have to compare two column's. The query should be like this
select * from employee e1, employee e2 where e1.id=e2.cid;
Correct me if i am wrong.


On 2014-06-09 11:20:41.0
hablu

copyright@questionsforum.net