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

The Archive Base Latest Questions

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

This is my first question here. I have a complicated SQL database and I

  • 0

This is my first question here. I have a complicated SQL database and I need to join different tables which have the same column names.

“event” is a sports match. It contains tournament_stageFK which is linked to tournament_stage table, which contains tournamentFK which is linked to tournament table, which contains tournament_templateFK which is linked to tournament_template table, which contains sportFK which is linked to sport table.

So in order to find out what sport the match is from, I need to do an inner join, otherwise I’d have to open the database millions of times. The only way to do it is this, but I don’t know how to display the results. My poor attempt to echo the results is below:

$SQL = "SELECT sport.name,
country.name, 
tournament_template.name, 
tournament.name, 
tournament_stage.name, 
event.* 
FROM tournament_template 
INNER JOIN sport
ON tournament_template.sportFK = sport.id 
INNER JOIN tournament ON tournament.tournament_templateFK = tournament_template.id 
INNER JOIN tournament_stage ON tournament_stage.tournamentFK = tournament.id 
INNER JOIN event ON event.tournament_stageFK = tournament_stage.id 
INNER JOIN country ON tournament_stage.countryFK = country.id 
WHERE DATE(event.startdate) = CURRENT_DATE() 
ORDER BY sport.name ASC, 
country.name ASC, 
tournament_stage.name ASC, 
event.startdate ASC"; 

$result = mysql_query($SQL);

while($get=mysql_fetch_array($result))
{
echo $result['event.name'];
echo "<br>";
}
  • 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:58+00:00Added an answer on May 27, 2026 at 6:31 pm

    You need to use column aliases and access those in your fetch call. Instead of event.*, be explicit about the columns you need:

    $SQL = "SELECT sport.name AS sportname,
    country.name AS countryname, 
    tournament_template.name AS templatename, 
    tournament.name AS tournamentname, 
    tournament_stage.name AS stagename, 
    /* Use explicit column names instead of event.* */
    event.name AS eventname,
    event.someothercol AS someother 
    FROM tournament_template 
    ...etc...
    ...etc...";
    
    // Later...
    while($row=mysql_fetch_array($result))
    {
      echo $row['eventname'];
      echo "<br>";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is my first time posting here, I have a question which I have
Hey stackoverflow - This is my first question here. I have 2 tables in
Greetings to all! This is my first question here on stackoverflow. I have a
this is my first question.. so, here we go. i have a site, 100%
Sorry, this's my first time to ask a question here. So, I don't have
Ok, I need help. This is my first question here. Background: I am working
this is my first question here. I have the following jquery code: $(document).ready(function(){ $(a).click(function(){
This is my first question here. I have been searching Stack Overflow and other
This is my first question here. I have a notepad app that you can
So this was one of my very first questions here, but I have 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.