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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:00:43+00:00 2026-06-04T13:00:43+00:00

Just to expand on my previous issue – I have two tables in my

  • 0

Just to expand on my previous issue – I have two tables in my database and I’ll like to extract certain information. Tables below:

   (player): player_id (primary), playerName
    (match): match_id (primary), playerID1, playerID2, playerID3, scorer etc..

You provided me with the following code to obtain the names of the players:

SELECT p.Name 
FROM `match` m
INNER JOIN `player` p 
    ON p.player_id IN (m.playerID1, m.playerID2, m.playerID3) //etc

Works beautifully thanks – there’s just two adjustments I’d like to make:

  1. I’d like to return the name of the scorer as well as the player names. Since m.scorer is an ID, how do I map it to the p.Name attribute if p.Name is already being mapped to m.playerID?
  2. The above query returns the names of all the players. I will soon be adding a search feature where you search for all matches for a certain player. Is there anyway of excluding that player from the results (seeing as we already know this player was in the match as he was searched for). So pretty much return all matches, and fellow players for a certain player, but exclude the actual searched player from the results. Sorry if this is unclear, let me know and I’ll expand on it.
  • 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-04T13:00:45+00:00Added an answer on June 4, 2026 at 1:00 pm

    Try something like the following (assuming field names). It will show you the name of the player, the matchId of the match it was and whether they scored in that match or not :).

    SELECT p.Name as 'Player Name', m.matchId as 'Match Id',
    CASE s.scorerId WHEN ISNULL(S.SCORERID,0) THEN 'YES' ELSE 'NO' END as 'Scored?',
    s.name as 'Scorer Name' --as requested from comment
    FROM match m
    INNER JOIN player p ON p.player_id IN (m.playerID1, m.playerID2, m.playerID3)
    LEFT JOIN scorer s ON s.matchId = m.matchId
        AND s.player_id IN (m.playerID1, m.playerID2, m.playerID3)
    

    See this SQLFiddle HERE

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

Sidebar

Related Questions

I just had a question about aligning two expand-collapse boxes and got an answer
Just a knowledge question which I would like to ask: For example, I have
I think I have not explained correctly. So i have just edited the previous
Or: How to expand the sensitive area for a UIControl without just making the
Just checking my JS and I have an error, but I cannot see where.
Just learning the world of jquery, and all my googling gives examples like this:
I am a web developer (J2EE application developer) and just want to expand what
I'm individually clicking through each caller's caller. Would prefer to just expand all and
I just want to expand this following method into something more generic, which should
The accordition menu has some top level items, these items when clicked just expand

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.