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



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

Answer / 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

More DB400 Interview Questions

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

0 Answers  


How to add a field to a PF and compile it without loss of data?

7 Answers  


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

0 Answers  


how to restrict upon adding the data for field reference file in DB400

1 Answers  


How to update physical file using logical file with example?

0 Answers  






I had created one physical file tell me command to enter data in to?

1 Answers  


i have a PF,it contains 5 members,how to access particular member data from logical file ?and what is the use of member in PF

3 Answers  


how to know total no of records in pf with out using sql??????

3 Answers  


pls anyone explain about compile time array,pre run time array run time array

4 Answers  


Last statement of any RPG pgm is LR?

5 Answers  


I have a PF with out any data but the dependent LF is having data?

1 Answers   HCL,


How to insert more than one record to a pf at a time?(Bulk insert to a pf)

9 Answers  


Categories