I have created an INNER JOIN query as shown below and was wondering how I can make it work? I need for the HomeTeam and AwayTeam to equal TeamID in the query. Any help would be much appreciated. Thanks
$result = mysqli_query($con,"SELECT results.*,team.TeamName
INNER JOIN team ON team.TeamID = results.HomeTeam
INNER JOIN team on team.TeamID = results.AwayTeam");
You need to use aliases for the table that you are including twice. Otherwise mysql cannot distinguish between the two.
To be able to process the results easily, you can do the same with the names you are selecting.
SELECT results.*, t1.TeamName AS TeamNameHome, t2.TeamName AS TeamNameAway FROM results INNER JOIN team t1 ON t1.TeamID = results.HomeTeam INNER JOIN team t2 ON t2.TeamID = results.AwayTeam