Table Name : Header
Id Name Pid
1 KYC
2 AP 1
3 IP 1
4 Security
Query:
SELECT H1.Id, H1.Name as Header, H2.Name as Parents
FROM Header H1
LEFT JOIN Header H2 ON H1.PID = H2.Id;
out put:
id header parents
1 KYC Null
2 AP KYC
3 IP KYC
4 Security Null
But actually i want
id header parents
1 KYC Null
2 KYC AP
3 KYC IP
4 Security Null
plz reply me...........