b.NAME,array_agg(t.name)FROMbooks bLEFTJOINtags tONt."id"=ANY( STRING_TO_ARRAY( b.tags,',') )GROUPBYb.ID, b.NAMEORDERBYb.ID-- 结果-- 01 Book01 {Tag01}-- 02 Book02 {Tag01,Tag02}-- 03 Book03 {Tag01,Tag02,Tag03}
在PostgreSQL中,string_to_array函数用于将字符串转换为数组。下面是对你问题的详细回答: string_to_array函数的作用: string_to_array函数的主要作用是将一个由指定分隔符分隔的字符串转换为数组。这在处理包含多个值的字符串时非常有用,尤其是在需要将这些值作为独立元素进行处理时。 string_to_array函数的基本语法...
SELECT string_to_array('xx~^~yy~^~zz', '~^~', 'yy'); content_copyCOPY https://w3resource.com/PostgreSQL/postgresql_string_to_array-function.php Save snippets that work from anywhere online with our extensionsComments commentAdd comment ...
',') from sys_dict_data sdd where CAST(sdd.dict_code as VARCHAR)= ANY(string_to_array( int...
2.STRING_TO_ARRAY 该函数用于分割字符串至数组元素,语法: string_to_array(string, delimiter [, null string]) string : 待分割的字符串 delimiter:指定分割字符串 null string : 设定空串的字符串 示例: SELECT string_to_array('xx~^~yy~^~zz', '~^~'); -- {xx,yy,zz} ...
In Postgresql, the regexp_split_to_array() function is used to split the specified string into an array using the specified POSIX regular expressions
STRING_TO_ARRAY函数将字符串分割为数组元素,并允许指定空字符串的替换值。 SELECTstring_to_array('xx~^~yy~^~zz','~^~');-- 返回 {xx,yy,zz}SELECTstring_to_array('xx~^~yy~^~zz','~^~','yy');-- 返回 {xx,NULL,zz} 1. 2.
SELECT UNNEST(String_To_Array('10;20;',';')) 我也尝试过: 代码语言:javascript 运行 AI代码解释 SELECT a,b FROM (select UNNEST(String_To_Array('12;5;25;10;2',';'))) a LEFT JOIN (select UNNEST(String_To_Array('12;5;25;10',';'))) b ON a = b 但没有得到正确的结果。 我不...
PostgreSQL provides various array functions such asARRAY_APPEND(), ARRAY_TO_STRING(), ARRAY_REPLACE(), etc.STRING_TO_ARRAY()is one of them. Each array function serves a unique functionality. For instance, the STRING_TO_ARRAY() function converts a string into an array. ...
In this post, I am providing a solution to split a string by using a different type of delimiters in PostgreSQL. Splitting a string is a very common requirement for all PostgreSQL Database Developers. I used regexp_split_to_array to split the string and store the result into a string ar...