Jump to content

[SOLVED] Sub query select?


ninedoors

Recommended Posts

I'm not sure if I can do this in one query or not without a sub query.

 

I have a schedule table that holds all the information about a hockey league schedule such as game_id(PRIMKEY), datetime, location, hometeam(INT), awayteam(INT), etc.

 

Then I have a another table that holds the teams names that play in the league.  It has a team_id column and then a name column.

 

How can get out the game information with the team names in one query.  Everything I try I can only get one of the names.  Here is the latest query I tried:

 

'SELECT sch.game_id, sch.game_date, t.alt_name FROM {db_prefix}osm_schedule as sch
                    LEFT JOIN {db_prefix}osm_teams as t ON(sch.hometeam = t.team_id)
                    LEFT JOIN {db_prefix}osm_teams as t ON(sch.awayteam = t.team_id)
                    WHERE sch.game_date >= NOW()  
                    ORDER BY sch.game_date
                    LIMIT 0, 1', 
                    array(
                        'team' => $context['user']['teams'][0],
                        ));

 

I am using the SMF structure for my site.  Thanks for the help.

 

Nick

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.