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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:31:53+00:00 2026-05-27T18:31:53+00:00

I have two tables, GAMES and USERS set up with the following fields: tblGAMES–>

  • 0

I have two tables, GAMES and USERS set up with the following fields:

tblGAMES-->
GAME_ID (int) primary key,
P1_ID (int),
P2_ID (int),
P3_ID (int),
P4_ID (int)

tblUSERS-->
USER_ID (int) primary key,
FIRST_NAME (text),
LAST_NAME (text)

I am querying my database to print out the details of every game row. Example:

GAME_ID:1, P1:1, P2:2, P3:3, P4:4

but instead of printing out the id which is stored in tblGAMES I would like to print out the first name of each player as it appears in the corresponding row in tblUSERS. Is this doable using a single query as opposed to multiple queries?

end result-->GAME_ID:1, P1:David, P2:Paul, P3:John, P4:Bobby
  • 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-27T18:31:53+00:00Added an answer on May 27, 2026 at 6:31 pm

    You’ll need to join the users table 4 times…

    select g.GAME_ID, 
           u1.FIRST_NAME as ulname, 
           u2.FIRST_NAME as u2name, 
           u3.FIRST_NAME as u3name, 
           u4.FIRST_NAME as u4name
    from tblGAMES as g 
      left join tblUSERS as u1 on g.P1_ID =u1.USER_ID 
      left join tblUSERS as u2 on g.P2_ID =u2.USER_ID 
      left join tblUSERS as u3 on g.P3_ID =u3.USER_ID 
      left join tblUSERS as u4 on g.P4_ID =u4.USER_ID 
    

    (untested)

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

Sidebar

Related Questions

I have two tables, both with start time and end time fields. I need
In a situation where I have two tables: Games(id, player1Id, player2Id) Players(id, gender) And
I have the following tables: Users - Users of the site Matchups - Matchups
What I have is a two tables. One table with users and another table
I have two tables: Toys and Games. +--------------------+------------------+ | Field | Type | +--------------------+------------------+
I have two tables: Teams id name Games id date idlocal idvisitor idlocal and
I have two tables. One is holding the titles of games. Another is holding
I have two tables: game `id` INT(11) game_tags `game` INT(11) `tag_id` INT(11) game_tags.game =
My Schema I have the following tables table notes/example values ------------------------------------------------ users ( id
I currently have two tables, one is called games, the other called rounds. Here

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.