Copyright © 2016 MariaDB. All rights reserved.
Get the Free Gartner Report on Optimizing with Open Source
How to get the depth of the graph?
WITH RECURSIVE graph as (
SELECT pr.*,@depth as depth FROM rcte_people_relationships pr WHERE source_id=3
SELECT pr.*,(@depth:=@depth+1) as depth FROM rcte_people_relationships pr, graph WHERE graph.target_id=pr.source_id
SELECT * FROM graph
CROSS JOIN (SELECT @depth := 0) AS depth;
Creates an infinite loop.
Download MariaDB and start working immediately! You can also get subscription details and learn more about the advantages of MariaDB's additional service offers.