path
此查询的结果仅在 order from是preserver时才有意义。但是,在我的左内连接时,结果被打乱了。我在想我可以在结果集中创建一个新列,就像结果的索引一样,然后作为整个 sql 的最后一个子句添加一个ORDER BY idx
.
这是我的查询,但未尝试保留最终订单:
SELECT path.*, network_link.v0prt
FROM (SELECT * // Need order preserved from this one
FROM shortest_path_shooting_star(
'SELECT gid as id, source::integer,
target::integer, distance::double precision as cost,
x1, y1, x2, y2, rule, to_cost FROM
network_link as net ORDER BY net.gid', 9, 1, false, false)) as path
LEFT OUTER JOIN
(SELECT DISTINCT gid, v0prt FROM network_link) as network_link
ON (network_link.gid=path.edge_id);
任何见解都会很棒。
谢谢。我尝试添加索引值和 ORDER BY (不起作用)。
SELECT path.*, network_link.v0prt
FROM (SELECT incr(0) as idx, *
FROM shortest_path_shooting_star(
'SELECT gid as id, source::integer,
target::integer, distance::double precision as cost,
x1, y1, x2, y2, rule, to_cost FROM
network_link as net ORDER BY net.gid', 9, 1, false, false)) as path
LEFT OUTER JOIN
(SELECT DISTINCT gid, v0prt FROM network_link) as network_link
ON (network_link.gid=path.edge_id)
ORDER BY idx;