0

The answer of this post here provides one single query to find all ancestors of a node in a adjacency list.

Now, how do I find all decendants of a node using similar query? I tried:

SELECT  @id :=
        (
        SELECT  receiverid
        FROM    mytable
        WHERE   senderid = @id
        ) AS person
FROM    (
        SELECT  @id := 5
        ) vars
STRAIGHT_JOIN
        mytable
WHERE   @id IS NOT NULL

I just swap senderid and receiverid, but it gives me #2014 Commands out of sync. You can't run this command now.

Any idea?

Community
  • 1
  • 1
Shawn
  • 2,675
  • 3
  • 25
  • 48
  • 1
    your schema? your recursion requirements? expected results should look like what shown chunk that you will show with an [edit] ? – Drew Jun 17 '16 at 20:11
  • Please see the post I linked to. It's the same. That post asked for finding all ancestors but I'm asking for finding all decendants. Thanks. – Shawn Jun 17 '16 at 21:31
  • yeah, just show the schema, load it with some data, and show expected results. It is your question. A sqlfiddle is how people do that. – Drew Jun 17 '16 at 21:32

0 Answers0