MySQL Forums
Forum List  »  Newbie

Recursive Query
Posted by: narayanan k
Date: October 27, 2014 11:18AM

Hello all,
I'm trying to search a table recursively.

a b c
-------
1 a 5
5 d 3
3 k 7
6 0 1
2 0 8

Currently I'm using the following query:
select a, @pv:=c as 'col3' from (select * from ListTest order by c asc) ListTest join (select @pv:=6)tmp where a=@pv;

When I search for 6, the o/p should be as
a b c
-----
6 0 1
1 a 5
5 d 3
3 k 7

Using above query I'm able to get the o/p as
a b c
-----
6 0 1
1 a 5

Can some one please help me to search the above table recursively for "6".

Thanks,
Narayanan

Options: ReplyQuote


Subject
Written By
Posted
Recursive Query
October 27, 2014 11:18AM
October 27, 2014 12:28PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.