i hv 3 field in a table and data.
currentid productname parentid
1 sports 0
2 cricket 1
3 Ball 2
4 Bet 2
5 Tennis 1
6 Racket 5
now i want to write query or store procedure from that i got reasult.
currentid productname parentid
1 sports 0
2 cricket 1
3 Ball 1
4 Bet 1
5 Tennis 1
6 Racket 1
means all the child find main parent id.
can any body help me.