Questions tagged [group-concat]

a function which returns a string representation of the concatenated, non-NULL values of a group

GROUP_CONCAT() or group_concat() is a function which returns a string representation of the concatenated, non-NULL values of a group.

This function is available in a variety of relational databases, including MySQL, SQLite, and MariaDB.

Resources

Related Tags

1334 questions
23
votes
1 answer

GROUP CONCAT not working for some reason

I'm forming a select statement and am getting this error. FUNCTION GROUP_CONCAT does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual I don't understand this because group concats worked with the code…
Optiq
  • 2,835
  • 4
  • 33
  • 68
19
votes
6 answers

sqlite3 JOIN, GROUP_CONCAT using distinct with custom separator

Given a table of "events" where each event may be associated with zero or more "speakers" and zero or more "terms", those records associated with the events through join tables, I need to produce a table of all events with a column in each row which…
aiwilliams
  • 193
  • 1
  • 1
  • 5
18
votes
3 answers

LEFT JOIN after GROUP BY?

I have a table of "Songs", "Songs_Tags" (relating songs with tags) and "Songs_Votes" (relating songs with boolean like/dislike). I need to retrieve the songs with a GROUP_CONCAT() of its tags and also the number of likes (true) and dislikes…
Lem0n
  • 1,217
  • 1
  • 14
  • 22
17
votes
10 answers

MySQL GROUP_CONCAT escaping

(NOTE: This question is not about escaping queries, it's about escaping results) I'm using GROUP_CONCAT to combine multiple rows into a comma delimited list. For example, assume I have the two (example) tables: CREATE TABLE IF NOT EXISTS `Comment`…
Bill Zeller
  • 1,336
  • 1
  • 9
  • 13
16
votes
6 answers

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 Drinking To: User Hobby -------------- Bob Football,…
John Paul Jones
  • 689
  • 4
  • 10
  • 17
16
votes
2 answers

Making a GROUP_CONCAT query more efficient

I have the following query. The idea is that it allows me to know what groups, and subsequently users, have access to each component_instance. I'm wondering if there is a better way to do this as the query is quite slow, but it's really handy to…
Brendon Muir
  • 4,540
  • 2
  • 33
  • 55
16
votes
4 answers

Using COUNT in GROUP_CONCAT

This is my table: id | fk_company ------------------- 1 | 2 2 | 2 3 | 2 4 | 4 5 | 4 6 | 11 7 | 11 8 | 11 9 | 12 The result I want should be…
mesnicka
  • 2,458
  • 8
  • 23
  • 31
15
votes
2 answers

How to concatenate data from one field, in a comma-delimited list, in a many-to-many relationship in MySQL?

I have a many-to-many relationship between People and Departments since one person can be in many departments. People Departments ------ ----------- pID pName deptID deptName 1 James 1 Engineering 2 Mary …
Shailen
  • 7,909
  • 3
  • 29
  • 37
14
votes
2 answers

Conditions in MySQL GROUP_CONCAT

I have a MySQL table with requests +--------+-------------+-----+ | req_id | req_name | ... | +--------+-------------+-----+ | 1 | testrequest | ... | +--------+-------------+-----+ and a table with votes on such…
Rapsey
  • 599
  • 2
  • 7
  • 17
14
votes
2 answers

GROUP_CONCAT in SQLite

I am having data like this 1 A 1 B 1 C 1 D 2 E 2 F 3 G 3 H 3 I 3 J 3 K by using this query select ABSTRACTS_ITEM._id,Name from ABSTRACTS_ITEM , ABSTRACT_AUTHOR , AUTHORS_ABSTRACT where ABSTRACTS_ITEM._id =…
user2579475
  • 1,051
  • 3
  • 11
  • 20
14
votes
2 answers

JOIN and GROUP_CONCAT with three tables

I have three tables: users: sports: user_sports: id | name id | name id_user | id_sport | pref ---+-------- ---+------------ --------+----------+------ 1 | Peter 1 | Tennis 1 | 1 | 0 2 |…
Peter
  • 5,138
  • 5
  • 29
  • 38
13
votes
2 answers

GROUP_CONCAT multiple fields with a different separator

Is it possible to do something like: GROUP_CONCAT(user, price SEPARATOR ', ') AS items The result is John3.99, Mike24.99 What I need is something like: John - 3.99, Mike - 24.99 Basically use another type of separator for price field.
Alko
  • 1,421
  • 5
  • 25
  • 51
12
votes
1 answer

is there a length limit to group_concat or another reason why it would not work on a text field

First, here is the query: SELECT GROUP_CONCAT(title) title, GROUP_CONCAT(description) description, skill_id, count(*) FROM jobs j INNER JOIN job_feed_details d ON j.id = d.job_id JOIN jobs_skills js ON j.id = js.job_id WHERE moderated = 1 …
jisaacstone
  • 4,234
  • 2
  • 25
  • 39
12
votes
3 answers

MySQL group_concat with where clause

I got this problem with Group_Concat and a where filter. In my table i got module names which are linked to a client. I want to search clients by module name, but in the group concat i still want to see all modules that are owned by the client.…
telefoontoestel
  • 357
  • 1
  • 2
  • 14
12
votes
1 answer

MySQL Group_Concat Repeating Values

I am working on an open source project called PHP-Bouncer, and I'm having issues with a MySQL Query I am writing for it. Basically we have three tables: BouncerRoles, PageInRole, and BouncerPageOverrides. BouncerRoles contains access levels, and the…
Brendon Dugan
  • 2,138
  • 7
  • 31
  • 65
1 2
3
88 89