what is use of self join and which cases you will use this join

Answer Posted / vidhya

A physical file can be joined to itself to read records that are formed by combining two or more records from the PF itself.
For example
You use a self join when a table references data in itself.

E.g., an Employee table may have a SupervisorID column that points to the employee that is the boss of the current employee.

To query the data and get information for both people in one row, you could self join like this:

select e1.EmployeeID,
e1.FirstName,
e1.LastName,
e1.SupervisorID,
e2.FirstName as SupervisorFirstName,
e2.LastName as SupervisorLastName
from Employee e1
left outer join Employee e2 on e1.SupervisorID = e2.EmployeeID

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to change the batch job to interactive job?

569


I have a pf, it contains 5 members, how to access particular member data from logical file?

522


In a CL Program after executing a SQL SP how to receive a Output value from the SP. Just to make it clear I am sending 2 input and 1 output parameter to the SQL Stored Procedure. Now while receiving it output parm it is failing.

2117


What is the use of member in pf?

529


What is FORMAT keyword and its use?

189






How to retrieve a physical file after deleting that?

576


There is one string as A B C and wanted to display string as Shri A Shri B Shri C, how we can do this in sql? If we have around 100 values in string like this, each value should be displayed with initials as Shri.

720


How many maximum record format a logical file have?

571


How to know the particular record in pf with out reading?

580


When we create a pf and did not fill up maint parameter, then by default which access path will the system take & why?

557


How to find the list of source physical files in a library?

606


How to update physical file using logical file with example?

574


How to index LF by relative record no (RRN)

2821


How to read a pf in reverse(from last record to first) using cl?

589


What is the batch job?

564