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
2 answers

MySql GROUP_CONCAT with GROUP BY every set of nth rows

SQL fiddle: http://sqlfiddle.com/#!9/e7f72/2 Assume a table called testt has 10 records in it (id is not null auto increment). If I were to do SELECT GROUP_CONCAT(id) FROM testt I would expect the results to look like 1,2,3,4,5,6,7,8,9,10 How…
user2278120
  • 623
  • 2
  • 9
  • 22
3
votes
2 answers

limit group_concat's resultset to actual results

I have the following query which is mostly working, but returns too many results within the group_concat() when one of the joined tables has a different number of results returned: select a.sku, a.ek, a.mwst, concat('[[',…
baao
  • 71,625
  • 17
  • 143
  • 203
3
votes
2 answers

GROUP_CONCAT with FIND_IN_SET, multiple joins

I want to retrieve items which have certain filters set. For example list items which are red or blue and small should return only the item apple. ((red(2) or blue(4)) and small(5)) => apple I have found 2 solutions, but both seem to me overly…
user5542121
  • 1,051
  • 12
  • 28
3
votes
1 answer

GROUP_CONCAT returns 1 row for 0 results

I hope this makes sense. I have a query that I'm running through PHP and as part of my query, I'm using GROUP_CONCAT. It works great and does everything I want but if the results are empty, it still returns 1 results with a series of NULL values. I…
b3tac0d3
  • 899
  • 1
  • 10
  • 15
3
votes
3 answers

MYSQL - Combine rows with multiple duplicate values and delete duplicates afterwards

So I have my database set up as a single table. In that table I have collected source URL and description (I am scraping the product description from a number of pages). Unfortunately I have ended up with multiple rows in the database for a…
Daniel Lee
  • 367
  • 5
  • 20
3
votes
1 answer

How to get the number of occurrence of each distinct value of GROUP CONCAT (php,mysql)

I know this is something very easy to do but i have not gotten the correct way to do it. i found something Here but different from what i need and no active contribution yet. Someone kindly assist. I have a table like this name…
scylla
  • 124
  • 9
3
votes
1 answer

Issue with group_concat() in Laravel 5

I am using group_concat() in my Laravel 5 model's Query. In this regard I use this statement. DB::statement('SET GLOBAL group_concat_max_len = 1000000'); It is working fine in Locally but it not working in Live online server. Could anyone say…
abu abu
  • 6,599
  • 19
  • 74
  • 131
3
votes
1 answer

MySQL group_concat SEPARATOR char or ascii

Is there a way in MySQL to define a SEPARATOR in group_concat() with a non printable sign? Like ascii 3 or something like that? i tried group_concat(text SEPARATOR char(3)) and group_concat(text SEPARATOR 3) both of them doesn´t work. Maybe a way…
Denis
  • 439
  • 4
  • 17
3
votes
1 answer

How to get mysql Group_Concat to work with additional CONCAT information?

I'm working on a web app with mysql involving a user role table where permission levels are stored as well as role ids and associated to usernames and their ids (redundancy to continue supporting legacy code). I want to be able to display every…
BZohar
  • 33
  • 3
3
votes
1 answer

MySQL SELECT statement that groups results by id?

I am trying to create a MySQL SELECT statement that will select a bunch of rows from a table and will group the results by the id of the row (multiple rows will have the same id). Here's an example of what I'm trying to do. Let's say I have the…
Rohan
  • 383
  • 3
  • 6
  • 14
3
votes
1 answer

Double results in GROUP_CONCAT with double JOIN in MySQL

I have the following tables: products Fields: id, title Values: (1,'Product 1') table1 Fields: id, idProduct Values: (1,1),(2,1) table2 Fields: id, idProduct Values: (3,1),(4,1) And the following query: SELECT p.*, GROUP_CONCAT(t1.id ORDER…
pandronic
  • 631
  • 2
  • 9
  • 21
3
votes
2 answers

Using GROUP_CONCAT creatively to avoid a query...can groups of records be retrieved?

I run a website with a small number of users that I hope will soon grow. I am using a shared web hosting service, and I cannot change MySQL default settings on the web server. I am trying to minimize queries and have found one recurring pair of…
flamePuppy
  • 61
  • 5
3
votes
1 answer

MariaDB GROUP_CONCAT only returns one value

I am experiencing a strange issue with the GROUP_CONCAT function in my instance, where using it to group together integers works just fine, but applying it to a varchar doesn't work at all. The data is along the lines of: CUSTOMERID LOCATIONNAME …
dwilkinson
  • 51
  • 3
3
votes
1 answer

How can I concatenate multiple values in a single field or column? (MySQL)

I have a table in MySQL that needs to be grouped. I am retrieving sales order with multiple items ordered My current database query looks like this: As you can see, sales order 255 has 2 items bought while sales order 300 has 3 items…
Nobunaga
  • 95
  • 9
3
votes
1 answer

select query into list on one column

I am trying to select all id into one column and delimit it with a comma , My DATA column: +---+--------+--------------+ |id |somedata|someother data| +---+--------+--------------+ |1 |data1 |other1 | +---+--------+--------------+ |2 …
majidarif
  • 18,694
  • 16
  • 88
  • 133