获得从&QUOT返回数组的第N个元素; string_to_array()"功能 [英] Get Nth element of an array that returns from "string_to_array()" function
问题描述
我正在寻找一种方式来访问数组的第N个元素是 string_to_array()
在PostgreSQL中函数的结果。例如,
假设单元格包含字符串值:一个简单的例子。如果我使用 string_to_array()
功能,我将有三个字符串数组为('A','简单','比如')。现在,无需存储(我的意思是,在飞)我要访问这个数组,这是肯定的简单的第二个元素。
在我的google搜索,我看到了一个例子来访问数组的最后一个元素,但这仅仅解决了我的问题。
有没有办法做到这一点?
选择(string_to_array('1,2,3,4',''))[2];
I am searching for a way to access to the Nth element of an array which is a result of string_to_array()
function in PostgreSQL. For example,
Assume that a cell contains the string value: "A simple example" . If I use string_to_array()
function, I will have an array of three strings as ('A','simple','example'). Now, without storing (I mean, on the fly) I want to access the 2nd element of this array, which is 'simple' for sure.
During my googling, I saw an example to access the last element of the array but this barely solved my problem.
Is there a way to do this?
select (string_to_array('1,2,3,4',','))[2];
这篇关于获得从&QUOT返回数组的第N个元素; string_to_array()"功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!