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
4
votes
1 answer

Condition within GROUP_CONCAT()

Guys I have the following tables in my DB locations id (primary key) name projects id (primary key) location_id (foreign key => locations) projectname milestones id (primary key) name statuses id (primary key) status project_milestones id…
Unknown Coder
  • 1,510
  • 2
  • 28
  • 56
4
votes
2 answers

doctrine2 and group_concat

i've been looking through the docs/google and didn't find any solution. is there any way to execute or imitate GROUP_CONCAT using doctrine2 (DQL) without native mysql? eg.: SELECT u.id, u.name, [GROUP_CONCAT(...)] AS user_messages FROM models\Users…
galchen
  • 5,252
  • 3
  • 29
  • 43
4
votes
3 answers

JPA Criteria API group_concat usage

I am currently working on a report which needs a group_concat for one of the fields. CriteriaQuery criteriaQuery = criteriaBuilder .createQuery(GameDetailsDto.class); Root betDetails =…
geneqew
  • 2,401
  • 5
  • 33
  • 48
4
votes
2 answers

Group by X or Y?

I'm trying to figure out how to GROUP BY on multiple columns. I want to group items when the SSN or the address matches. For example, here are three records: account_number | name | ssn |…
Jason Swett
  • 43,526
  • 67
  • 220
  • 351
4
votes
3 answers

Trouble with GROUP_CONCAT and Longtext in MySQL

The SQL... UPDATE Threads t SET t.Content = ( SELECT GROUP_CONCAT(a.Content ORDER BY a.PageID SEPARATOR '') FROM MSarticlepages a WHERE a.ArticleID = t.MSthreadID GROUP BY a.ArticleID ) As you can see it takes all of…
Iwasakabukiman
  • 1,453
  • 4
  • 15
  • 17
4
votes
1 answer

MySQL UPDATE with GROUP_CONCAT joining three tables

The goal: update T1 with GROUP_CONCAT info from T3 with JOIN across T2. Here’s a simplified version of the table structures: T1: xfer_lectures Relevant fields: lecture_id, topics (I'm trying to fill the topics field with a concatenated list of…
codebird
  • 357
  • 7
  • 17
4
votes
1 answer

order by within group concat

The order by is not working in the second query. I need to order by first DNAID then DNBID First Query its ordered as: 111221 Second Query its ordered as: 112112 for more info and details about what im…
user391986
  • 29,536
  • 39
  • 126
  • 205
4
votes
2 answers

select all rows with same column to separate columns in mysql

I have a table like this : fkey | sensor | depth | value -----+--------+-------+------- 1 | 1 | 1 | 34 1 | 1 | 2 | 27 1 | 2 | 1 | 22 1 | 2 | 2 | 34 1 | 2 | 3 | 56 2 | 1 | 1 |…
Mojtaba Arvin
  • 679
  • 1
  • 10
  • 21
4
votes
0 answers

MySQL group_concat(utf8) in union truncated to 1024/3

TLDR: group_concat(utf8 varchar) union itself returns only group_concat_max_len/3 ASCII characters as if the character length was fixed instead of variable. The group_concat alone returns group_concat_max_len characters as expected. The problem I…
Jakub Fojtik
  • 681
  • 5
  • 22
4
votes
2 answers

SQL Group_concat not get all data

I have 2 table and second table use relationship table1 id name --------- 1 alpha 2 beta table2 id name relation ------------------- 1 2015 2 2 2016 2 3 2017 2 4 2018 2 I want to see name …
vciloglu
  • 526
  • 2
  • 7
  • 19
4
votes
2 answers

SELECT WHERE id IN GROUP_CONCAT

How do I use a WHERE or HAVING clause in combination with a GROUP_CONCAT such that the returned data will include any combination of items in the GROUP_CONCAT that contain the ID not just the single match e.g. SELECT…
Alistair Weir
  • 1,809
  • 6
  • 26
  • 47
4
votes
2 answers

GROUP_CONCAT with dplyr or R

I am having difficulty replicating the functionality of a typical SQL GROUP_CONCAT function in dplyr. I would also like to make sure the ordering inside the groups can be controlled. Ideally I want to use the hadleyverse/tidyverse but base R or…
rikturr
  • 409
  • 6
  • 7
4
votes
3 answers

GROUP_CONCAT in Vertica

Suppose we have data something like this: date | campaign | raw | unq ------------+----------+-----+----- 2016-06-01 | camp1 | 5 | 1 2016-06-01 | camp2 | 10 | 1 2016-06-01 | camp3 | 15 | 2 2016-06-02 | camp4 | 5 |…
Vadim Kasich
  • 51
  • 1
  • 1
  • 2
4
votes
2 answers

Sorted data in groups

Dataset: id uid activity postid 1 20 A 1 2 20 A 1 3 6 A 1 4 3 A 1 5 6 A 1 6 13 A 1 7 13 B 1 8 18 B …
Shaharyar
  • 12,254
  • 4
  • 46
  • 66
4
votes
2 answers

MySQL group_concat() ordering by case statement values

In a MySQL group_concat() clause, I'm trying to order the resulting values of a case statement. The following query configuration properly orders things.name but does not order the 'Non-US' or 'Unknown' values within the same context. SELECT …
s2t2
  • 2,462
  • 5
  • 37
  • 47