All Questions

1349
votes
39answers
1630563 views

Concatenate many rows into a single text string?

Consider a database table holding names, with three rows: Peter Paul Mary Is there an easy way to turn this into a single string of Peter, Paul, Mary?
869
votes
9answers
469917 views

Can I concatenate multiple MySQL rows into one field?

Using MySQL, I can do something like: SELECT hobbies FROM peoples_hobbies WHERE person_id = 5; and get: shopping fishing coding but instead I just want 1 row, 1 col: shopping, fishing, coding ...
162
votes
4answers
93345 views

Postgresql GROUP_CONCAT equivalent?

I have a table and I'd like to pull one row per id with field values concatenated. In my table, for example, I have this: TM67 | 4 | 32556 TM67 | 9 | 98200 TM67 | 72 | 22300 TM99 | 2 | 23009 TM99...
180
votes
6answers
159878 views

MySQL and GROUP_CONCAT() maximum length

I'm using GROUP_CONCAT() in a MySQL query to convert multiple rows into a single string. However, the maximum length of the result of this function is 1024 characters. I'm very well aware that I can ...
67
votes
6answers
172025 views

How to use GROUP_CONCAT in a CONCAT in MySQL

If I have a table with the following data in MySQL: id Name Value 1 A 4 1 A 5 1 B 8 2 C 9 how do I get it into th...
120
votes
5answers
88205 views

MySQL DISTINCT on a GROUP_CONCAT()

I am doing SELECT GROUP_CONCAT(categories SEPARATOR ' ') FROM table. Sample data below: categories ---------- test1 test2 test3 test4 test1 test3 test1 test3 However, I am getting test1 test2 test3...
4
votes
5answers
6435 views

Show a one to many relationship as 2 columns - 1 unique row (ID & comma separated list)

I need something similar to these 2 SO questions, but using Informix SQL syntax. Concatenate several fields into one with SQL SQL Help: Select statement Concatenate a One to Many relationship My...
16
votes
6answers
28608 views

Use LINQ to concatenate multiple rows into single row (CSV property)

I'm looking for the LINQ equivalent to the Sybase's LIST() or MySQL's group_concat() It'll convert: User Hobby -------------- Bob Football Bob Golf Bob Tennis Sue Sleeping Sue Drinkin...
132
votes
2answers
62644 views

MySQL: Sort GROUP_CONCAT values

In short: Is there any way to sort the values in a GROUP_CONCAT statement? Query: GROUP_CONCAT((SELECT GROUP_CONCAT(parent.name SEPARATOR " » ") FROM test_competence AS node, test_compete...
22
votes
5answers
33659 views

GROUP_CONCAT with limit

I have table with player-s in many-to-many relation with skill-s The goal is to list the players and their "top 3 skills" with a single query. fiddle create table player( id int primary key ); c...

Previous Next