What is Self Join ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is Self Join ?

Joining the table itself called self join. Self join is used to retrieve the records having some relation or similarity with other records in the same table. Here we need to use aliases for the same table to set a self join between single table and retrieve records satisfying the condition in where clause. Syntax SELECT a.column_name, b.column_name... FROM table1 a, table1 b WHERE a.common_field = b.common_field; Sample Code SELECT e1.EmpId, e1.EmpName FROM EmployeeDetails e1, EmployeeDetails e2 where e1.EmpId=e2.ManagerId;

8th Dec 2016, 6:52 AM
Akwin Lopez
Akwin Lopez - avatar
1 Answer
+ 1
Is this an answer in the form of a question? Because the answer's right up there and should probably be down here.
8th Dec 2016, 10:03 AM
Kirk Schafer
Kirk Schafer - avatar