如何获取表数据而不提及行\u到\u json中的列名称

w51jfk4q  于 2021-07-24  发布在  Java
关注(0)|答案(1)|浏览(332)

下面的脚本非常适合指定的列,我得到了预期的结果。但我想从表中获取所有列。谢谢您的帮助。

SELECT row_to_json(fc) FROM (
 SELECT 'FeatureCollection' As type, array_to_json(array_agg(f)) As features FROM(
  SELECT 'Feature' As type, ST_AsGeoJSON(lg.geom)::json As geometry,
      row_to_json((id, name)) As properties FROM coffee_shops As lg
    ) As f
) As fc
qlzsbp2j

qlzsbp2j1#

要包含所有字段(包括几何图形),您需要将表名或别名传递给 row_to_json ```
select
row_to_json(lg) As properties FROM coffee_shops As lg

相关问题