|
i have a table with 3 columns. and my table column TID is auto Incremented(1,1) ..now i need to display the out put like now what my requirement is i want to show the Description column 2 times .one time as Parent and another time as Description .... and my task is if PID=0 means He is parent..if PID!=o then it is child i want to dispaly in parent column........
(comments are locked)
|
can you try this? Not tested
(comments are locked)
|
|
I think there's a typo in your sample data - I think for TID = 4 you should have ParentID = 0 and then for TID = 5, 6 and 7 ParentID should be 4. Assuming that's the case then LEFT JOINing the data to itself should give you what you need as the code below shows....
(comments are locked)
|
|
If the demo data is altered slightly then this works:
(comments are locked)
|


in your sample data you have
is this correct?