gpt4 book ai didi

sql - 我们什么时候可以在 PostgreSQL 中使用标识符号而不是它的名称?

转载 作者:行者123 更新时间:2023-11-29 12:12:40 28 4
gpt4 key购买 nike

我正在开发一个需要删除用户提供的数字的软件,但不幸的是一些元素,如列名(与用户输入无关)也可以用数字表示。因此,我正在寻找一个完整的引用资料,以了解列名或(可能是表名)何时可以在查询中由 id 表示。

例如在下面的查询中这种情况成立:

 select * from first group by 1,2,3;

最佳答案

输出 列的位置引用在 GROUP BY and ORDER BY 中有效SELECT 语句的子句。

GROUP BY Clause
expression can be an input column name, or the name or ordinal number of an output column (SELECT list item)

ORDER BY Clause
Each expression can be the name or ordinal number of an output column (SELECT list item)

还有DISTINCT ON :

The DISTINCT ON expressions are interpreted using the same rules as for ORDER BY.

例子:

关于sql - 我们什么时候可以在 PostgreSQL 中使用标识符号而不是它的名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24596290/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com