Still learning SQL :) This time I'd like to a 'linked list' walk from a table I guess using CTE. Despite all the example on the web I could not find one simple example I could start from then peek and poke from there.
Here is my table
create table yo (id integer, nx integer) select * from yo id nx
1 5 2 4 3 7 4 9 5 3 6 0 7 0 8 6 9 8
I'd like to get a list of 'id','nx' from yo following the next link 'nx' given a start 'id'
So a start 'id' of 1 would produce id nx
1 5 3 7 5 3 7 0
Note that 0 is a end marker.
I can't find the magic SQL for doing this Thanx in advance Cheers, Phi
Aucun commentaire:
Enregistrer un commentaire