0

我正在从 pgrouting a Practical Guide 书中做一个示例,但是使用我自己的表格,我遇到了这个错误。我已经使用 LIMIT 1 来避免这个错误,就像书中的例子一样,但肯定还有另一个错误。关于修复的任何想法?

错误:

用作表达式的子查询返回的不止一行

SELECT *
    FROM pgr_drivingDistance(
    'SELECT id, source, target,
        cost
        FROM network.roads',
    (SELECT v.id
      FROM network.master_table AS h
        ,LATERAL (SELECT id FROM network.roads_vertices_pgr  AS n
           ORDER BY h.geom <-> n.the_geom LIMIT 1 ) AS v),
       5000, false, false
    );
4

1 回答 1

1

限制 1 开启

SELECT id FROM network.roads_vertices_pgr  AS n
       ORDER BY h.geom <-> n.the_geom LIMIT 1

错误在整个子查询上,

(SELECT v.id
      FROM network.master_table AS h
        ,LATERAL (SELECT id FROM network.roads_vertices_pgr  AS n
           ORDER BY h.geom <-> n.the_geom LIMIT 1 ) AS v)

这是该子查询CROSS JOIN LATERALnetwork.master_table结果(您知道它是一行)。因此,如果 network.master_table 上的 SELECT 返回多于一行,则会出现该错误。

于 2017-09-04T23:13:59.260 回答