“选择"与“来自"相同的表是什么意思? [英] What does `select` the same table as `from` mean?

查看:42
本文介绍了“选择"与“来自"相同的表是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定一张桌子

mytestdb=# select * from foo;
 id | name 
----+------
  4 | Tim
(1 row)

select foo from foo 输出是什么意思,即 selectfrom 同一个表是什么意思?谢谢.

what does select foo from foo output, i.e. what does select the same table as from mean? Thanks.

mytestdb=# select foo from foo;
   foo   
---------
 (4,Tim)
(1 row)

谢谢.

我的问题来自于理解

mytestdb=# select json_agg(foo) from foo;
        json_agg         
-------------------------
 [{"id":4,"name":"Tim"}]
(1 row)

http://johnatten.com/2015/04/22/use-postgres-json-type-and-aggregate-functions-to-map-relational-data-to-json/

推荐答案

在选择列表中使用表名或别名 生成 表当前行的复合值.将表名或别名传递给可以接受复合值的函数,将为每一行调用该函数.

Using a table name or alias in a select list generates a composite value of the table's current row. Passing the table name or alias to a function that can accept a composite value will invoke the function for each row.

这篇关于“选择"与“来自"相同的表是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆