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 perticular record in pf with out reading?

2 Answers   Cap Gemini,


how to update physical file using logucal file with example

1 Answers   Wipro,


wirte a simple program for read file in cl

2 Answers   Active Brains,


YOU CAN DELETE THE RECORD SPACE PERMENANTLY IN PHYSICALFILE THROUGH CL?

4 Answers  


how to eliminate the level check error

2 Answers   TCS,






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

9 Answers  


Where the QTEMP library will get created? if the the answer is QSYS, then howcome more than one job can create same library name(QTEMP) in QSYS? what is the uniqueness of QTEMP? For example, run the below command in different workstation WRKOBJ QSYS/QTEMP And take 8 in the option to check the description. both will have different info. so where(which LIB) exactly the QTEMP is stored?

2 Answers  


Why we create the Physical File Member?

5 Answers  


There are six records in a file and we are going to update that records and used commit operation when it complete the update but suppose when it updating the third record,a error occured and operation failed.Is previously two records will be update or whole operation will be rollback? Please confirm it.

2 Answers  


how to add a new field to a file without compiling it?

1 Answers  


CRTDTA AND CRTARA should be used along with?

2 Answers  


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

1 Answers   HCL,






Categories