Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7775893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:44:23+00:00 2026-06-01T17:44:23+00:00

Problem: I have a GROUP_CONCAT query that is working as intended, except I’d like

  • 0

Problem: I have a GROUP_CONCAT query that is working as intended, except I’d like to make the concat a joined answer, not the raw ID field.

Current query:

SELECT user.user_id, user.user, GROUP_CONCAT(user_roles.roleID separator ', ') roles
FROM user
JOIN user_roles ON user.user_ID = user_roles.user_ID
GROUP BY users.user_ID, users.user

Gives result:

+----------+---------+----------------------------+
|  user_ID | user    |   roles                    |
+----------+---------+----------------------------+
|        1 |   Smith |    1, 3                    |
+----------+---------+----------------------------+
|        2 |   Jones |    1, 2, 3                 |
+----------+---------+----------------------------+

Desired result:

+----------+---------+----------------------------+
|  user_ID | user    |   roles                    |
+----------+---------+----------------------------+
|        1 |   Smith |    Admin, Other            |
+----------+---------+----------------------------+
|        2 |   Jones |    Admin, Staff, Other     |
+----------+---------+----------------------------+

User table:

+----------+---------+
|  user_ID | user    |
+----------+---------+
|        1 |   Smith |
+----------+---------+
|        2 |   Jones |
+----------+---------+

*users_roles table:*

+----------+---------+
|  user_ID | role_ID |
+----------+---------+
|        1 |   1     |
+----------+---------+
|        2 |   1     |
+----------+---------+
|        2 |   2     |
+----------+---------+
|        2 |   3     |
+----------+---------+
|        1 |   3     |
+----------+---------+

roles table:

+----------+-----------+
|  role_ID | role_name |
+----------+-----------+
|        1 |   Admin   |
+----------+-----------+
|        2 |   Staff   |
+----------+-----------+
|        3 |   Other   |
+----------+-----------+
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:44:25+00:00Added an answer on June 1, 2026 at 5:44 pm

    try the following query

    SELECT user.user_id, user.user, GROUP_CONCAT(roles.role_name  separator ', ') roles
    FROM user
    JOIN user_roles ON user.user_ID = user_roles.user_ID
    JOIN roles ON user_roles.role_ID= user_roles.role_ID
    GROUP BY users.user_ID, users.user
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i would like to have a query that will solve my problem in native
I have a tree / ancestor / query problem I'm not able to solve:
I have a problem incorporating a Group_Concat function in my SQL query. I have
I've seen that a few instances of this problem have been raised already. However,
Problem: I have two spreadsheets that each serve different purposes but contain one particular
I have a strange performance problem with a query used to create a filter
I currently have database setup like so: CREATE TABLE `article` ( `id` int(11) NOT
I have a query that returns as a result what seems to be a
I have a MySQL query below that I'm using to get events for my
I have a query which uses the GROUP_CONCAT of mysql on an integer field.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.