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

MYSQL: Combine duplicate rows

I have a issue where I need to combine a bunch of duplicate data. I'm starting with a table that was merged from two different sources. An example of the data would be: aID, bID, value1, value2, value3, value4 The issue is that there are situations…
bmilner
  • 43
  • 5
4
votes
1 answer

MySQL SELECT from multiple tables, multiple GROUP BY and group_concat?

I have three tables which I want to query in MySQ. As follows: **Table: Leaderboard** Name | Score ------------ James | 1 Steve | 2 Dave | 5 **Table: Actions** Name | Action | Time ---------------------------- James | Ate an apple |…
lufc
  • 1,965
  • 2
  • 15
  • 19
3
votes
2 answers

Combining rows of queried results by unique identifier?

I have a query that searches through several tables and returns one row for every value in one specific column of one of the queried tables. The table returns multiple rows for one unique identifier. What I want to do is combine those rows that have…
broguyman
  • 1,386
  • 4
  • 19
  • 36
3
votes
1 answer

MySQL Left Outer Join and Combining Results

I'm struggling with a join. Basically I want the tags results from my query to be in a single row. Below are my tables: cover category cover_tag tag The query returns the cover, category, and all tags for that category. NULL results in the tags…
GV1
  • 475
  • 1
  • 10
  • 17
3
votes
2 answers

How to join 3 tables with group_concat

I am using Cubecart for a customer website, and they have used comma-separated values to associate certain option IDs to products. I need to create a custom table which gets all this information out into a format so that I can assign different…
Dan
  • 1,154
  • 1
  • 7
  • 14
3
votes
1 answer

mysql & group_concat_length

Let say I have a table with million of rows. Does this sql query stop as soon as "group_concat_length" limit value is reached for all "id_list" or does it test all rows in the table? SELECT GROUP_CONCAT(id) AS id_list, type FROM table WHERE 1 GROUP…
Darm
  • 5,581
  • 2
  • 20
  • 18
3
votes
2 answers

How to write SQLite code to show a specified code along with its associated codes from group_concat function?

I am trying to create a table where the code N09 is included, where a student was assigned a set of codes that contains N09, and "Status Complete" was yes. I wanted to use group_concat to see if each set contains N09. I saw a similar question to…
mq19745422
  • 73
  • 5
3
votes
1 answer

Recursive join and group_concat with SQLite

I have the following table: id value successor_id -- ----- ------------ 1 v1 2 2 v2 4 4 v3 null 7 v4 9 9 v5 null 12 v6 null Note: Those are simple paths…
Toxiro
  • 528
  • 1
  • 3
  • 12
3
votes
1 answer

Question on using multiple SQL GROUP BY statements

So ultimately I am trying to display the total number of times a pitcher has won the Cy Young award in my baseball league, and then the Season Year(s) they won it in, but sorted by League Name, since a pitcher could have won the award in different…
Dan
  • 43
  • 4
3
votes
1 answer

Why is MySQL using 4 bytes for each character when selecting something from a derived table when it has a concat() using a utf8mb4 charset?

Starting from this table with a utf8mb4_unicode_ci collation: DROP TABLE IF EXISTS preferences; CREATE TABLE IF NOT EXISTS preferences ( id int auto_increment primary key, user_id int not null, title varchar(150) not…
Sneakyvv
  • 136
  • 5
3
votes
4 answers

Use SQLite SELECT to combine joined table column into one row for each category using a junction table

I am using SQLite and have three tables (there is more data in these tables - abbreviated here): Categories - Holds item categories (id, name, description) Items - (id, name, status) Reference (id, cat_id, item_id) Categories can have many items…
Vento
  • 33
  • 3
3
votes
2 answers

Has anybody discovered a (simple) way to limit group_concat rows?

I have a pretty big query to pull out the information about reports from each country, and right now, the only way I can limit this is by putting Limit 10 or some number at the end, which will limit the countries. However, what I want to do is limit…
Ryan Ward Valverde
  • 6,458
  • 6
  • 37
  • 48
3
votes
1 answer

GROUP_CONCAT with additional grouping?

I have started on a script to generate statistics of how often and when a particular article is called using SELECT `title`, `page_id`, COUNT(*) AS `total`, GROUP_CONCAT(DISTINCT `date_created` ORDER BY `date_created` SEPARATOR ',')…
Taff
  • 231
  • 1
  • 13
3
votes
2 answers

How to return JSON_ARRAY using an GROUP_CONCAT

I've try return json object using "concat" and "group_concat" functions. Problem is that I need to use group_concat but I want to have a valid JSON structure. What I do wrong? {"a":"a", "b": "b", "id": null} [{"id": "123"}] ... SELECT…
IkyryguJava
  • 83
  • 1
  • 9
3
votes
3 answers

mysql group by using the range record value

In SQL I have table t_test below: emp_code | period_month | company_code NIK001 | 01 | ALPHA NIK001 | 02 | ALPHA NIK001 | 03 | ALPHA NIK001 | 04 | ALPHA NIK001 | 05 | ALPHA NIK001 | 06…
yuda
  • 121
  • 1
  • 7