Jump to content

[SOLVED] Need help with pulling data from two tables...


galvin

Recommended Posts

My tables have more fields than this, but I will only list the ones that apply to this problem...

 

TABLE 1 (called "runningbacks"):

 

playerid, teamid

 

TABLE 2 (called "opponents"):

 

teamid, week1opp

 

Before TABLE 2 came into the mix, I had the following MySQL query...

 

$sql = "SELECT playerid, teamid
FROM runningbacks;

 

 

Simple enough, but now I need to expand on that query to also look to this other table called "opponents" and bring back the proper value for "week1opp" based on the the teamid (for EVERY single playerID that it brings back)...

 

So, for example, let's say "runningbacks" had the following info...

 

playerid/teamid

1001/3

1002/6

1003/5

1004/5

1005/19

1006/6

etc, etc....

 

And let's say table "opponents" had...

 

teamid/week1opp

1/Raiders

2/Saints

3/Cowboys

4/Ravens

5/Steelers

6/Cardinals

etc, etc.

 

I need the query to find that for playerid 1001, the "week1opp" is "Cowboys"....for playerid 1002, the "week1opp" is "Cardinals" and so on.

 

I believe this is simple but I'm having trouble.  Can anyone help?...

 

 

 

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.