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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:56:19+00:00 2026-06-13T22:56:19+00:00

Database: MySQL Table: Teams TeamID INT TeamName VARCHAR(20) Table: People PeopleID INT FirstNameID INT

  • 0

Database: MySQL

Table: Teams

TeamID    INT
TeamName  VARCHAR(20)

Table: People

PeopleID   INT
FirstNameID INT
LastNameID  INT

Table: TeamMembers

TeamID  INT
PeopleID  INT

Table Example: Teams

TeamID       TeamName
1            Team Xstream
2            Team INsanity

Table Example: People

PeopleID   FirstNameID   LastNameID
1          1351          453
2          5463          763
3          976           8762
4          87            784
5          187           465
6          761           566
7          376           2134

Table Example: TeamMembers

TeamID       PeopleID
1            1
1            3
1            7
2            2
2            4
2            5
2            6

Desired Output:

TeamName       TeamMembers
Team Xstream   John Smith/Jane Doe/Daniel Davis
Team INsanity  Sally Sue/Tom Thomas/Jack Jones/Harry Henderson

There will not be a set number of TeamMembers per team, so it’s not like I could have three subqueries because there will only be three team members. I’ve lightly looked online, but I always get the best and most thorough answers here. Any ideas or pointers, please let me know. I honestly have no idea where to begin here. Thanks.

  • 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-13T22:56:20+00:00Added an answer on June 13, 2026 at 10:56 pm

    I am guessing that the names of the people are actually stored somewhere considering you are just showing ID numbers as names. But you will want to use both CONCAT() and GROUP_CONCAT() for this result. The first step, will join all of the tables and use the CONCAT() function:

    select t.teamname,
     concat(p.FirstNameId, ' ', p.LastNameId) teamMembers
    from teams t
    left join teammembers m
      on t.teamid = m.teamid
    left join people p
      on m.peopleid = p.peopleid;
    

    See SQL Fiddle with Demo, which will produce the result:

    |      TEAMNAME | TEAMMEMBERS |
    -------------------------------
    |  Team Xstream |    1351 453 |
    |  Team Xstream |    976 8762 |
    |  Team Xstream |    376 2134 |
    | Team INsanity |    5463 763 |
    | Team INsanity |      87 784 |
    | Team INsanity |     187 465 |
    | Team INsanity |     761 566 |
    

    Once you have the data, then apply the GROUP_CONCAT() function and GROUP BY the teamname:

    select t.teamname,
      group_concat(concat(p.FirstNameId, ' ', p.LastNameId) SEPARATOR '/') teamMembers
    from teams t
    left join teammembers m
      on t.teamid = m.teamid
    left join people p
      on m.peopleid = p.peopleid
    group by t.teamname;
    

    See SQL Fiddle with Demo

    results:

    |      TEAMNAME |                     TEAMMEMBERS |
    ---------------------------------------------------
    | Team INsanity | 761 566/87 784/187 465/5463 763 |
    |  Team Xstream |      976 8762/376 2134/1351 453 |
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a many to many table setup in my mysql database. Teams can
I have a many to many table setup in my mysql database. Teams can
Database setup (MySQL) table: top_fives id, uid, first, second, third, fourth, fifth, creation_date 1,
I have a MySQL database table called Participant that looks something like this: (idParticipant)
In one of my Mysql database table the dates are stored in the format
i have a large mysql database table in which one column contains values ranging
Say I've got a mySQL database table with 4 fields: link_id (primary key) page_id
I want to convert the mysql database table contents to an Excel(.xls) or comma
I want to insert a record into a MySQL database table from a formulaire.
Is there any application that will read a MySQL database table and generate a

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.