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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:20:54+00:00 2026-06-10T03:20:54+00:00

I am trying to create a simple player profile website and am running into

  • 0

I am trying to create a simple player profile website and am running into a problem with my SQL.

I have a player table and a previous clubs table. As this is a many-to-many relationship, I am using a look up table (player previous clubs) between the player and previous clubs table.

This all seemed to be working fine until I ran my sql which looks like this:

SELECT player.id, player.name AS name, age, position, height, weight, previousclubs.name AS previousclubs, satscore, gpa
FROM player 
INNER JOIN playerpreviousclubs
ON player.id = playerid
INNER JOIN previousclubs
ON previousclubid = previousclubs.id

The problem is that if a player has more then one previous club, then all of the information (apart from the previous club) is duplicated so I end up with something like this.

RESULT SET 1

Name: John Smith
Age: 23
Previous Clubs: Arsenal

RESULT SET 2

Name: John Smith
Age: 23
Previous Clubs: Reading

What I would like it to do is the following:

RESULT SET 1

Name: John Smith
Age: 23
Previous Clubs: Arsenal, Reading

Can anyone explain to me why this is currently happening please and how I go about rectifying it.

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-10T03:20:55+00:00Added an answer on June 10, 2026 at 3:20 am

    You have to use GROUP BY combined with aggregate function in order to achieve wished behaviour (i.e. you need to “aggregate” n-tuples retrieved from DB, that’s why the functions are called aggregate :-)). Choice of aggregate function depends on RDBMS you are using, for example:

    MySQL:

    SELECT player.id, player.name AS name, GROUP_CONCAT(previousclubs.name)
    FROM player
    INNER JOIN playerpreviousclubs ON player.id = playerid
    INNER JOIN previousclubs ON previousclubid = previousclubs.id
    GROUP BY player.id, player.name
    

    PostgreSQL (v8.4 and higher):

    SELECT player.id, player.name AS name, array_agg(previousclubs.name)
    FROM player
    INNER JOIN playerpreviousclubs ON player.id = playerid
    INNER JOIN previousclubs ON previousclubid = previousclubs.id
    GROUP BY player.id, player.name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a simple widget to retrieve a users feeds, I have
I'm trying to create a simple youtube player that should show thumbnail of videos
I have written a simple audio player on android(below). And trying to run on
I'm trying to create a simple video player with 3 buttons: play, stop and
I'm trying to create a simple youtube player using some javascript. Example is here:
I'm trying to create a simple mp3 player using FMOD: #include inc/fmod.h int main()
I am trying to create a simple audio player that will work in iOS
I'm trying to create a simple media player interface using WPF. Though I'm a
I'm trying to create simple PayPal Pay API operation, when I run this code
I'm trying create simple application in C++. This application has to read from file

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.