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

Correct way of using grunt's "bower_concat" and "angular-i18n"

If one is not using grunt's "concat" and "bower_concat", angular-i18n is used this way: ... ... …
sports
  • 7,851
  • 14
  • 72
  • 129
4
votes
1 answer

Get all joined records when one match is found

Here's simple test database that should explain my problem: CREATE TABLE `articles` ( `article_id` int(11) NOT NULL AUTO_INCREMENT, `article_title` varchar(50) NOT NULL, PRIMARY KEY (`article_id`) ); INSERT INTO `articles` VALUES(1, 'first…
patwork
  • 150
  • 4
4
votes
1 answer

MySQL group_concat and count

I am trying to get the aspects of each category in a single query as follows: SELECT b.`id` AS parent_id, b.`name` AS parent_name, a.`id` AS child_id, a.`name` AS child_name, a.`pageid` AS t_id, COUNT( c.`id` ) AS deals_in_cat, …
web-nomad
  • 6,003
  • 3
  • 34
  • 49
4
votes
3 answers

Mysql group_concat adds a separator for empty fields

There is a sample schema in here: http://sqlfiddle.com/#!2/c0723a/2 query is select id,group_concat(val) from test group by id result is ID GROUP_CONCAT(VAL) 1 ,64,66,,203,214,204 I wanted to concat val field without a comma for empty…
zgormez
  • 429
  • 5
  • 9
4
votes
3 answers

MySQL: Group and flatten elements on a column

If I have a view: Movie Genre Actor ------------------------------------------- Ocean's Twelve Crime George Clooney Ocean's Twelve Crime Julia Roberts Ocean's Twelve Crime Brad Pitt Forrest Gump Drama Tom…
user2066880
  • 4,825
  • 9
  • 38
  • 64
4
votes
1 answer

mysql query, how can i get top 5 downloads with GROUP_CONCAT

the following data in MySql table. brand_id|image_id|downloads --------|--------|--------- 8 |9 |8 35 |2829 |4 28 |2960 |3 28 |2961 |3 28 |3041 |3 35 |2831 |3 28 |2965 …
Girish
  • 11,907
  • 3
  • 34
  • 51
4
votes
1 answer

new line separator doesn't work for group_concat function

I have a string (name lastname,name2 lastname2...) with values from a database table and I want to display it like: name lastname name2 lastname2.. I use group_concat function it works for commma separators but I need new line…
KB9
  • 599
  • 2
  • 7
  • 16
4
votes
1 answer

Order by inside Group_concat

This is my fiddle. Table and data is create table Table3 (MatchID varchar(10), ItemType varchar(10)); insert into Table3 values ('M001','Fruit'), ('M001','Animal'), ('M002','Fruit'), ('M002','Vehicle'); When you have a select query orderd by…
Praveen Prasannan
  • 7,093
  • 10
  • 50
  • 70
4
votes
1 answer

group_concat was cut when running a query on table

I have a table that looks likes this: and this table contains 343 rows. I'm trying to run this query on it: create table newTest2 select function_name, service_name, min(concurrency), substring_index(group_concat(date order by concurrency ),…
tkyass
  • 2,968
  • 8
  • 38
  • 57
4
votes
2 answers

Using NOT IN with GROUP CONCAT in MYSQL

I'am using the "GROUP_CONCAT" function with the "NOT IN" statement in my mysql query. But for unknown reason, it doesn't return the correct values: Here is my query not working: select firstname, lastname from t_user where (status_Id NOT IN(Select…
Gael Stucki
  • 41
  • 1
  • 2
4
votes
2 answers

Join top 3 interest fields along with each user row

I'm trying to get the top 3 interests of each user, probably as a LEFT JOIN query. The way the app is designed, each user has a set of interests which are no other than 'childs' (rows without parent) of the categories table. Here are some simplified…
Guillermo
  • 185
  • 6
4
votes
4 answers

Using GROUP_CONCAT column alias in CASE statement with LIKE

The idea here is that the GROUP_CONCAT compiles a list of option codes out of the stock table joined to the option_stock and options tables, grouped by the stock id. An example row is this: Name Options …
Paul
  • 133
  • 2
  • 9
4
votes
2 answers

MySQL Query GROUP_CONCAT Over Multiple Rows

I'm getting name and address data out of generic question / answer data to create some kind of normalised reporting database. The query I've got uses group_concat and works for individual sets of questions but not for multiple sets. I've tried to…
PeteGO
  • 5,597
  • 3
  • 39
  • 70
4
votes
1 answer

Find duplicate records and give result in concat string

I have 2 tables where some of the records will be identical (except for the id) Table A: id, numA, codeA 6, 34, aa 7, 34, bb 8, 567, bc Table B id, numB, codeB 1, 34, aa 2, 34, bb 3, 567, bc I need to run a query on Table B which will…
Victoria B
  • 79
  • 7
4
votes
1 answer

MySQL - How to use subquery into IN statement by value

The question is to get table column data and use it as a value list for IN function; For this example I created 2 tables: movies and genres Table "movies" contains 3 columns: id, name and genre. Table "genres" contains 2 columns: id and name. +-…
George
  • 1,466
  • 3
  • 12
  • 30