referencing a column from query?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
tennis_blues
Forum Newbie
Posts: 21
Joined: Sun Oct 20, 2002 8:30 am

referencing a column from query?

Post by tennis_blues »

hi all,
i have a query:

SELECT Schedule.PlayDate, HT.TeamID, AT.TeamID FROM Schedule, Team HT, Team AT WHERE (Schedule.HomeTeamID = 1 or Schedule.AwayTeamID = 1) and (HT.TeamID = Schedule.HomeTeamID) and (AT.TeamID = Schedule.AwayTeamID)

which produces the following result:
PlayDate TeamID TeamID
2002-09-10 5 1
2002-09-17 4 1
2002-09-24 1 18
2002-10-01 1 6
2002-10-08 17 1
2002-10-15 10 1
2002-10-22 1 9
2002-10-29 1 7
2002-11-05 19 1

my problem is here: how in a PHP script do I get both TeamIDs

I tried
$row("HT.TeamID") and $row("AT.TeamID")
$row("TeamID(1)") and $row("TeamID(2)")
$row("TeamID[1]") and $row("TeamID[2]")

but no matter what i try, i get an undefined index error....

can someone please point me in the right direction?

thanks so much in advance for your help!
meg
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

try

Code: Select all

print_r($row);
to see what's in...
if nothing else helps try

Code: Select all

SELECT Schedule.PlayDate, HT.TeamID as hteamID, AT.TeamID as ateamID
Post Reply