On 12/2/2014 2:46 PM, Paul Sanderson wrote:
So what I really need is to
a) ensure that the ordering of the recursive query is guranteed, i.e.
the order follows the ID/parent relationship to the root
b) a method of concatenating this in reverse order

WITH RECURSIVE rcte AS (
  SELECT 0 as level, parent, FileName
  FROM rtable
  WHERE ID = 510
UNION ALL
  SELECT rcte.level + 1 as level, rtable.parent, rtable.FileName
  FROM rcte JOIN rtable ON rcte.parent = rtable.ID
  WHERE rtable.FileName <> '.')
SELECT FileName
FROM rcte
ORDER BY level desc;

--
Igor Tandetnik

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to