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

mysql group_concat on multiple tables

This is the first time I ever use stackoverflow,.. be gentle on me ;) I have little problem here with getting duplicated results from GROUP_CONCAT when using more than one JOIN on the map tables. It is not easy to explain this, but I will try: I…
TLBang
  • 33
  • 4
3
votes
2 answers

How could I pass the separator as a variable in MySQL GROUP_CONCAT?

I would like to pass the SEPARATOR value of a GROUP_CONTACT as a variable (or function parameter), however this code will fail SET @sep = ' '; SELECT `group`, GROUP_CONCAT( `field` ORDER BY `idx` SEPARATOR @sep ) `fields` FROM `table` GROUP…
3
votes
2 answers

pandas equivalent of groub by with STRING_AGG for several columns

So is there a way to groupBy a DataFrame object and then for the remaining columns, put all the entries into a set (or list with filtered unique values). So something like this Name Date Amount purchase 0 Jack 2016-01-31 10 …
Todor Popov
  • 77
  • 3
  • 6
3
votes
1 answer

MySQL GROUP_CONCAT add slashes

I'm trying to return the results of a poll in JSON format. My first SQL is this SELECT fa.pollQuestion_id, q.title, JSON_OBJECT( 'text', qo.title, 'total', COUNT(fao.pollQuestionOption_id) ) values FROM pollFillAnswers fa INNER JOIN…
monchyrcg
  • 372
  • 1
  • 6
  • 16
3
votes
3 answers

Loop through and combine schemas/tables with UNION_ALL

I want to combine tables from different schemas using UNION_ALL. The tables have the same schema, like in this toy example: class1.names +----------+ | id | name| +----------+ | 1 | jon | | 2 | ann | | 3 | rob | class2.names +----------+ | id |…
JTa
  • 181
  • 1
  • 12
3
votes
1 answer

MySQL: Increasing GROUP_CONCAT_MAX_LEN param - any dangers?

Right now, my MySQL server is using the default value of 1024 bytes for the GROUP_CONCAT_MAX_LEN, and I need to increase it. I am aware of the fact it is constrained by the MAX_ALLOWED_PACKET param, which is currently very sufficient in size. Will…
Nadav
  • 119
  • 1
  • 1
  • 8
3
votes
0 answers

OPTIONAL not working with SPARQL query on local YASGUI editor

I am once again having trouble with SPARQL. First off, a bit of background information: I have been using the Wikidata Query Service to retrieve data from Wikidata. As the Wikidata SPARQL endpoint is limited and timeouts occur for large tasks, I…
3
votes
1 answer

MYsql GROUP_CONCAT with 3 columns execute in PHP

i have query that has subselect that may return more than 1 result: SELECT t1.group, (SELECT GROUP_CONCAT(t3.id,','t3.name,','t3.age SEPARATOR('---') FROM table t3 WHERE t3.id= t2.id GROUP BY t3.id )) AS names, FROM table1…
i-faith
  • 449
  • 1
  • 3
  • 14
3
votes
1 answer

How to multiple concatenate values from multiple relation tables in a single mysql query

I have a big issue for my "traveling offer" project, working 99% OK, but not 100%. I have main table with offers, where each offer can have set multiple department cities as well as multiple destination cities (this is reduced sample with reduced…
3
votes
2 answers

modify the values achieved through group_Concat in MySql?

I have the following [table a] id res1 res2 1 a f 1 b f 1 b f 1 c f 2 e g 2 e g 2 e g 2 f g I'm getting the following after doing…
goonerboi
  • 309
  • 6
  • 18
3
votes
1 answer

IN mysql function group_concat change separator dynamically

I want to use separator for group_concat() function in mysql.But I want to change the separator dynamically.I mean the separator value is coming from a table and that is different for every row. I couldn't found any solution for that please help…
3
votes
1 answer

is increasing group_concat_max_len to 500000 will cause a performance issue?

I have mysql 5.6 installed. I have a query that uses group_concat to concatenate a list of user ids into one string with ','. i need to increase the limit of group_concat_max_len to 500000. will that cause a performance issue? why group_concat is…
ufk
  • 30,912
  • 70
  • 235
  • 386
3
votes
3 answers

MySQL: How to sort when using concat in group_concat?

I need to sort date in concat within group_concat while my query is running fine: SELECT report.`Name`, GROUP_CONCAT( CONCAT( "[", DATE(report.Date) --(not working) order by DATE(report.Date) , ',', …
skhurams
  • 2,133
  • 7
  • 45
  • 82
3
votes
1 answer

MySQL varchar column on group_concat shows as text in View

I have column in base table as acct_num varchar(25) and I am creating a View and GROUP_CONCAT() is set to this column. This is shown as text datatype in show create view. Is it possible to have VARCHAR(25) datatype for GROUP_CONCAT(acct_num) column.…
user4033385
  • 553
  • 1
  • 7
  • 16
3
votes
1 answer

Sparql group_concat - Stop Ordering

I'm fairly new to SPARQL, and am experiencing some interesting behaviour that I do not understand. So I have four genes: a-gene b-gene c-gene d-gene and two strains: strain1 strain2 and the following triples: strain1 hasGene a-gene strain1…