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

Condition in GROUP_CONCAT selection

I have 3 tables and I'm joining them to get some data. ----------------- Table Name: users ------------------------------- |user_id | user_name | ------------------------------- 123 | abc ------------------------------- 223 |…
user2595861
  • 73
  • 1
  • 2
  • 9
2
votes
1 answer

MySQL GROUP_CONCAT excluding group value

I am trying to do a group concat for the table below l r num A B 1 A C 3 A A 5 B C 5 B C 7 B C 9 C A 1 C A 2 C C 3 I would like get the group concat of those elements which do not belong to the group when we…
Dinesh
  • 2,194
  • 3
  • 30
  • 52
2
votes
2 answers

GROUP_CONCAT numbering

is it possible to have numbering in GROUP_CONCAT like If, from GROUP_CONCAT(empnam SEPARATOR ', ') I get a set, < JohnM, DannyP, TiffnyK, KarlM > I need to have < 1.JohnM, 2.DannyP, 3.TiffnyK, 4.KarlM > I tried following, but didnt get…
Hytool
  • 1,358
  • 1
  • 7
  • 22
2
votes
2 answers

ORDER BY whether a GROUP_CONCAT contains a certain value?

I have properties and I need to list the ones mapped as "Founding Members" first, and then alphabetically while the rest that aren't need to come afterwards and be listed alphabetically. properties table: ------------------------ id name 1 Gaga…
meder omuraliev
  • 183,342
  • 71
  • 393
  • 434
2
votes
1 answer

MySQL Query: Values from multiple cells in a single cell

There is a table name agents which contains a list of agents and another table named projects, which contain list of projects and IDs of agent working on that project. The output I am looking for is a list of agents, a total count of projects they…
Ahsan Arshad
  • 116
  • 2
  • 15
2
votes
1 answer

Get records from third table

I have three tables, and duplicate column names also :) I want to join albums to products and images to albums. Images are many. Trying such query, it gives me duplicate products. Is there a chance to grab everything in one query? SELECT …
cssBlaster21895
  • 3,670
  • 20
  • 33
2
votes
1 answer

How to avoid group_concat separator duplicate in mysql select result

I have 2 tables call record and user, their fields are below record fields: recordID (key) userID (key) user fields: userID (key) userName userNote and I want to know recordID, userName, userNote group by recordID Here is my sql select…
Benson
  • 21
  • 1
2
votes
2 answers

MySQL Select query to fetch record base on list values

I am using MySQL. I have 3 Table as below. Table : subject_Master -------------------------- subjectId | subjectShortName ---------------------------------- 1 | English 2 | French 3 | German 4 | …
fresher
  • 399
  • 4
  • 23
2
votes
2 answers

GROUP CONCAT not working in a subquery - mysql

I have a mysql query which I've written in order to grab a group of attributes in the database based on IDs, which relate to a specific group. I'm using OpenCart 2 for my site, and my subquery is as follows: SELECT GROUP_CONCAT(attribute_id) AS…
Michael Emerson
  • 1,774
  • 4
  • 31
  • 71
2
votes
1 answer

Getting multiple data from several tables

I try to get data from two connected tables. $query="SELECT a.*, (SELECT `city_id` FROM `staff-city`) as cities FROM `staff` as a WHERE a.id=2"; i get the error: Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[21000]:…
Dmitry Web
  • 29
  • 1
  • 5
2
votes
2 answers

Changing mysql query to combine multiple columns instead of of seperate lines

I have 2 tables like this: Table: Company id| Name | Area 1 | Company A | New York 2 | Company B | New York 3 | Company C | Chicago Table: Service id| Type 1 | Service 1 | Delivery 2 | Hotel 2 | Restaurants 3 | Movers I would like…
somanit
  • 23
  • 2
2
votes
2 answers

keep distinct key and concat column

I have a table for translation for example: | key | language | value ---------------------------------------------- | hi | en | hello | hi | es | hola | delete | …
Xerton Web
  • 43
  • 3
2
votes
1 answer

mysql self join with group_concat and without duplicates

I would like to get rid of duplicates in my DB. There can be several duplicates of one criterion, which are then grouped together. Let's say B is duplicate of A, and C is also duplicate of A then there should be a result like *id* | *duplicate* …
user2979506
2
votes
1 answer

MySQL - nested result concatenation

I got 3 tables (from sakila sample db) : film, film_actor and actor. Film: (1000 rows) film_id | title | .... ______________________ 1 | a | .... 2 | b | .... 3 | c | .... 4 | d | .... 5 | e |…
MisterP
  • 447
  • 1
  • 3
  • 17
2
votes
1 answer

SQLite, Many to many relations, How to aggregate?

I have the classic arrangement for a many to many relation in a small flashcard like application built using SQLite. Every card can have multiple tags, and every tag can have multiple cards. This two entities having each a table with a third table…
Vasily
  • 316
  • 3
  • 12