Tag:Comma separated
-
PostgreSQL converts a comma separated string to a multiline instance
–Converts a comma separated string to multiple lines SELECT unnest(string_to_array(‘4513,4564,555′,’,’)) as a1; –Array to row SELECT unnest(ARRAY[1,2]); SELECT * from unnest(ARRAY[1,2],ARRAY[‘foo’,’bar’,’baz’]); Supplement: PostgreSQL row to column, column to row string function and string segmentation function This paper mainly introduces the row to column, column to row and string cutting functions of PostgreSQL. The first two […]
-
PostgreSQL query collection results are separated by commas, and the operation of returning string processing
keyword: string_agg(” , ”) For example: select string_agg(name||” , ‘,’) from sys_user Supplement: the PostgreSQL field is separated by comma “,” to judge whether it contains a value Array Functions and Operators https://www.postgresql.org/docs/9.2/functions-array.html — —————————- — Table structure for T_STUDENT — —————————- DROP TABLE IF EXISTS “public”.”T_STUDENT”; CREATE TABLE “public”.”T_STUDENT” ( “id” int4, “name” varchar(255) […]
-
SQL Sever uses SQL statements to merge duplicate row data into one row and separate them with commas
1、 Define table variables Copy codeThe code is as follows: DECLARE @T1 table ( UserID int , UserName nvarchar(50), CityName nvarchar(50) ); Insert into @ T1 (user ID, user name, city name) values (1, ‘a’,’shanghai ‘)Insert into @ T1 (user ID, user name, city name) values (2, ‘B’,’Beijing ‘)Insert into @ T1 (user ID, user […]