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

Search GROUP_CONCAT using LIKE

I have an SQL query that uses GROUP_CONCAT to get all people attached to a certain order. Is there a way I can search inside the GROUP_CONCAT field? SELECT orders.orderID, GROUP_CONCAT(contacts.firstName, " ", contacts.lastName) AS…
gen_Eric
  • 223,194
  • 41
  • 299
  • 337
11
votes
1 answer

mysql workbench "Lost connection to mysql server"

First I need to indicate that I ran the sql file for the Wikipedia dump on my machine, and to be able to run that I needed to update many settings regarding the index size available on memory and some other settings. I just want to mention that…
Andi Keikha
  • 1,246
  • 2
  • 16
  • 37
11
votes
2 answers

MySQL: combining multiple values after a join into one result column

I have a database with a table for publications, each of which can have multiple authors that are stored in a different table. I'd like to query the database into giving me a list of publication titles in one column, and the combined authors for…
Ack
  • 283
  • 1
  • 4
  • 11
11
votes
2 answers

Use GROUP_CONCAT result in IN Clause Mysql

I have a Query which returns comma separated integers like : select GROUP_CONCAT(ids) from table2 now I want to use that result in another query like : select * from table1 where column in (select GROUP_CONCAT(ids) from table2) in this case it…
Yogesh Prajapati
  • 4,770
  • 2
  • 36
  • 77
10
votes
0 answers

string_agg is not recognized built-in function name - SQL Server 12.0

I want to group by a table by some columns and show values of other column.in SQL v.2017 I can do that with string_agg function. but my SQL version is 2012.How can I do that... create table dbo.TaskPeriods ( [id] [int] NULL, [startDate] [datetime]…
mohammadrg
  • 151
  • 1
  • 8
10
votes
1 answer

Delete duplicate records based on two columns in MySql

I want to delete the extra duplicate record i.e. in the image shown there are two records with corporate_id = 5 and category_id = 19, how to delete any one row which is duplicate (here corporate_sed_id is the primary key)
K Arun Singh
  • 2,629
  • 3
  • 20
  • 34
10
votes
6 answers

Group_concat - laravel eloquent

please I want to use group_concat in a query using eloquent and not raw queries. here is the code which i tried to execute and did't work for me: commands::join('products', 'products.id',…
user3481058
  • 313
  • 2
  • 4
  • 18
9
votes
7 answers

Show a one to many relationship as 2 columns - 1 unique row (ID & comma separated list)

I need something similar to these 2 SO questions, but using Informix SQL syntax. Concatenate several fields into one with SQL SQL Help: Select statement Concatenate a One to Many relationship My data coming in looks like this: id …
CheeseConQueso
  • 5,831
  • 29
  • 93
  • 126
9
votes
4 answers

MySQL: UPDATE with a JOIN and a GROUP_CONCAT

Is this possible? I have 2 tables, Customers and Orders. Now I want to fill a column in Customers with all order id's of that customer (comma separated). I tried something like this, but it doesnt work: UPDATE customers AS c LEFT JOIN orders AS o…
Dylan
  • 9,129
  • 20
  • 96
  • 153
9
votes
1 answer

How to add separator to Concat options when using Usemin

I am using Grunt-usemin. But the concatenated JS is not properly separated by ';'. How do I tell usemin to add the separator only for JS files but not CSS files? Currently, my usemin tasks look like this: useminPrepare: { options: { …
Codier
  • 2,126
  • 3
  • 22
  • 33
9
votes
2 answers

MySQL - GROUP_CONCAT returns duplicate data, can't use DISTINCT

I have a normalized database and I'm trying to return data from multiple tables using JOINs and GROUP_CONCAT. Problem: Rows are being duplicated with GROUP_CONCAT. I can't use DISTINCT because some of the data (ingredient mfr) does need to be…
Matt Shultz
  • 312
  • 3
  • 10
9
votes
3 answers

How to use sum() within a group_concat()?

Question revised Really wanted a group_concat of sums... Table: shops +---------+--------+--------+ | shop_id | name | state | +---------+--------+--------+ | 0 | shop 0 | 5 | | 1 | shop 1 | 5 | | 2 | shop 2 | 5 …
Mahks
  • 6,441
  • 6
  • 28
  • 31
9
votes
2 answers

GROUP_CONCAT() row count when grouping by a text field

DROP TABLE IF EXISTS `table`; CREATE TABLE `table` ( `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, `text` text COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8…
Michael
  • 11,912
  • 6
  • 49
  • 64
8
votes
1 answer

How to find all the tags of each page and then concat the tags into one column?

How can I find all the tags of each page and then concat the tags into one column? For an example, pages table, page_id 1 2 3 4 tags table, tag_id tag_name 1 A 2 B 3 C 4 D tagged table, page_id …
Run
  • 54,938
  • 169
  • 450
  • 748
8
votes
4 answers

Mysql IF IN GROUP_CONCAT breaks

Im doing a fairly big SQL so I apologizes that cant provide a bigger example of my tables. SELECT customer_id, agreement_id, if( 'network' IN ( GROUP_CONCAT( DISTINCT services.service_code SEPARATOR ',' ) ), …
Cleric
  • 3,167
  • 3
  • 23
  • 24