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

  • Home
  • SEARCH
  • 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 8635807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:03:58+00:00 2026-06-12T10:03:58+00:00

I have data for a game where in one table are the game stats

  • 0

I have data for a game where in one table are the game stats and in another table is the game information like home team, away team, game date, and winner. I’m looking for a way to join the game info data with the stats data. The stats data is configured so that the first five players are the home team and the second five players are the away team.

game info schema:
gamelog( gameid, gamedate, hometeam, awayteam, winner )
gamestats( gameid, index, player, points, rebounds, … )

I would like my output to be:

  • home, hometeam, player, points, rebound
  • home, hometeam, player, points, rebound
  • home, hometeam, player, points, rebound
  • home, hometeam, player, points, rebound
  • home, hometeam, player, points, rebound
  • away, awayteam, player, points, rebound
  • away, awayteam, player, points, rebound
  • away, awayteam, player, points, rebound
  • away, awayteam, player, points, rebound
  • away, awayteam, player, points, rebound

I can’t seem to find a way to do a join so that the team column has its first five names as the home team and the second five names as the away team. The only way I have managed to do it is with two additional columns each with ten team names in them ie:

SELECT gamelog.hometeam, gamelog.awayteam, gamestats.player, gamestats.points, gamestats.rebounds 
    WHERE gamestats.id = 18873
    AND gamelog.id = gamestats.id;
  • hometeam, awayteam, player, points, rebound
  • hometeam, awayteam, player, points, rebound
  • hometeam, awayteam, player, points, rebound
  • hometeam, awayteam, player, points, rebound
  • hometeam, awayteam, player, points, rebound
  • hometeam, awayteam, player, points, rebound
  • hometeam, awayteam, player, points, rebound
  • hometeam, awayteam, player, points, rebound
  • hometeam, awayteam, player, points, rebound
  • hometeam, awayteam, player, points, rebound

I guess another possibility would be to do multiple queries through PHP and then combine the data after the queries are done, though I am not sure if that would be more efficient. I could also add a column into the gamestats table that has the team names, but that seems redundant.

Edit: Posted the schema’s and cleared up the language

  • 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-12T10:03:58+00:00Added an answer on June 12, 2026 at 10:03 am

    I figured it out. Had to do a join the first five rows of the gamestats table with the gamelog table home team name and then UNION the second five rows of the gamestats table with the game log table away team name.

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

Sidebar

Related Questions

I have a games table which holds the data about a game. Then another
I have data like the following: var data = [{ id: 1, date: new
What I have is a two tables. One table with users and another table
All, I have a table that looks like this: Date Pitcher WHIP -------- --------------
I have a sample data game(id, name) 1 | Avatar 2 | Angry Bids
I have built a game in HTML5 and a web form posts data to
I have created a small game in Java and I would like to add
I am looking to make a small rpg game using php/mysql/javascript but I have
I have made a high score activity for my game. i used table row
I have a table which stores highscores for a game. This game has many

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.