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?...

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.