SQL :将 2 个语句与 2 个 SELECT 组合
SQL : combine 2 statements with 2 SELECT
如何将这 2 个 SQL 语句合并为一个?
我想在此处替换值 shape
:
SELECT path[1] AS number, st_x(geom), st_y(geom)
FROM st_dumppoints(shape)
通过这个 :
SELECT shape
FROM tableA
WHERE id = 'test'
像这样:
SELECT path[1] AS number, st_x(geom), st_y(geom)
FROM st_dumppoints(SELECT shape FROM tableA WHERE id = 'test')
只需在子选择周围添加一对额外的括号。从语法上讲,子查询需要括号,函数调用也需要,所以你最终得到
FROM st_dumppoints((SELECT shape FROM tableA WHERE id = 'test'))
注意,如果子查询returns多于一行,语句会报错。
如何将这 2 个 SQL 语句合并为一个?
我想在此处替换值 shape
:
SELECT path[1] AS number, st_x(geom), st_y(geom)
FROM st_dumppoints(shape)
通过这个 :
SELECT shape
FROM tableA
WHERE id = 'test'
像这样:
SELECT path[1] AS number, st_x(geom), st_y(geom)
FROM st_dumppoints(SELECT shape FROM tableA WHERE id = 'test')
只需在子选择周围添加一对额外的括号。从语法上讲,子查询需要括号,函数调用也需要,所以你最终得到
FROM st_dumppoints((SELECT shape FROM tableA WHERE id = 'test'))
注意,如果子查询returns多于一行,语句会报错。