3 table SQL Join Query - TechRepublic
General discussion
January 25, 2006 at 09:06 AM
dryflies

3 table SQL Join Query

by dryflies . Updated 19 years, 11 months ago

Three tables, GameSched, UmpSched, GameLoc.
PK stands for Primary Key, FK is Foreign Key.
GameSched has Day,Date,Time,Home,Away,Location,ID(PK)
GameLoc has Name,Url,ID(PK)
UmpSched has First,Second,Third,Plate,GameNo(FK),ID(PK)

The following query retrieves an Empty Set. However, I can query GameSched with GameLoc or GameSched with UmpSched and retrieve the appropriate records. I know I need a JOIN but am not sure about the syntax.
Any Suggestions?
$query_AllUmpGames = “SELECT GameSched.`Day`, GameSched.`Date`, GameSched.`Time`, GameSched.Division, GameSched.Home, GameSched.Visitor, GameSched.Location, GameSched.ID, GameLoc.`url`, UmpSched.Plate, UmpSched.First, UmpSched.Second, UmpSched.Third, UmpSched.GameNo FROM GameSched, diamonds, UmpSched WHERE ( UmpSched.GameNo = GameSched.ID ) && ( `GameSched`.`Location` LIKE `GameLoc`.`name` )”;

This discussion is locked

All Comments