我正在尝试解决这个问题,我给了一个数据库表,例如:create table file(id int,parentid int,name varchar(1024),size int,type 炭(1));
我写了类似的东西但是,我不确定这是否是我要求我做的问题,因为我没有经验的Unix。任何帮助将不胜感激。感谢
WITH RECURSIVE search_path (path_ids, length, is_visited) AS
(
SELECT
ARRAY[node_id, destination_node_id],
link_length,
node_id = destination_node_id
FROM
node_links_view
UNION ALL
SELECT
path_ids || d.destination_node_id,
f.length + d.link_length,
d.destination_node_id = ANY(f.path_ids)
FROM
node_links_view d,
search_path f
WHERE
f.path_ids[array_length(path_ids, 1)] = d.node_id
AND NOT f.is_visited
)
SELECT * FROM search_path
WHERE path_ids[1] = 1 AND path_ids[array_length(path_ids, 1)] = 6
ORDER BY length;