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 6226497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:02:26+00:00 2026-05-24T09:02:26+00:00

I have the following tables: users id | name info id | info |

  • 0

I have the following tables:

users

id | name

info

id | info | user_id

(user_id from table info is foreign key => connects to id from table users)

It is possible that the user will have many entries in the info table (same user_id in many rows).

Now I want to fetch data and display it like that:

username:

... info ....

Example:

admin:

aaa

bbb

ccc

someuser:

ddd

eee

fff

So I use LEFT JOIN like that:

SELECT users.name, info.info
FROM users
LEFT JOIN info
ON users.id = info.user_id

But what I get is the following:

admin:

aaa

admin:

bbb

admin:

ccc

How can i display the username only once? I’ve tried using DISTINCT keyword after SELECT but it didn’t help. Meanwhile i solve this problem inside the php code itself, but is there any way to fix this only inside the sql?

  • 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-05-24T09:02:26+00:00Added an answer on May 24, 2026 at 9:02 am
    SELECT users.name, GROUP_CONCAT(info.info SEPARATOR 'whateveryouwant') as info
    FROM users 
    INNER JOIN info ON (users.id = info.user_id)
    GROUP BY users.name
    

    By default group_concat uses a , as separator, but you can change that if needed.

    Link:
    http://dev.mysql.com/doc/refman/5.5/en/group-by-functions.html#function_group-concat

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following tables questions -> id, question_data, user_id users -> id, fname, lname
I have 3 tables with the following columns : * users : user_id *
I have following tables: users(id, name) posts (id, text, userId) comments (id, text, userId,
I have the following tables in MySQL: users profile rates In the users table,
I have the following tables: team_members userid teamid users uid name_f name_l friends friend_id
I have the following 3 tables: team_data id team_id team_name team_members userid teamid users
I have the following tables: Users: userId , userFirstName , userLastName . holdBilling: bEntityID
In my application I have the following tables: Posts id title content Users id
I have a table [Users] with the following columns: INT SmallDateTime Bit Bit [UserId],
I have a table with sets of settings for users, it has the following

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.