Home > DeveloperSection > Forums > What is a self join in sql server
Ankit Singh

Total Post:341

Posted on    December-06-2015 10:09 PM

 Database SQL Server  SQL  SQL Server 2008  SQL Server 2012 

 2 Reply(s)
 553  View(s)
Rate this:
I want to know Self join in sqlserver How to use It.please help me.

aditya kumar Patel

Total Post:254

Posted on    December-06-2015 11:12 PM

A self join is basically when a table is joined to itself. The way you should visualize a self join for a given table is by imagining that a join is performed between two identical copies of that table. And that is exactly why it is called a self join – because of the fact that it’s just the same table being joined to anothercopy of itself rather than being joined with a different table.

SELECT e1.Emp_ID,e1.Emp_Name,e1.Emp_Sal

FROM employee e1, employee e2

WHERE e1.Location = e2.Location

AND e2.Location='allahabad'

Ankit Singh

Total Post:341

Posted on    December-07-2015 10:34 PM

self join is a join in which a table is joined with itself. For example, when you require details about an employee and his manager (also an employee)

Don't want to miss updates? Please click the below button!

Follow MindStick