Forum Moderators: coopster
I need some help with my code. What I want to do is to get the last game that the team played. But the thing is that i have 2 columns that are home and away. So i cant just say in my where clause where away=$team. I have to say where away=$team or home=$team because the team could be away or home i never know. I have 2 tables, calendar and team. In the calendar table you have all the info about the games and in the team table you have the list of the team. I need this table to make a join to make a link between the home or away team and the TeamID in my team table. I dont know if im really clear but here's my query :
SELECT * FROM calendar,team where calendar.away = calendar.home = team.city and (calendar.home='Detroit' or calendar.away='Detroit') order by calendar.GameNo desc limit 1
calendar.home = home team during the game
calendar.away = away team during the game
team.city = whatever team in the list
The output of this query is 50% good. Because they give me the good GameNo with the good teams. But when its with the part of the team table. It gives me the first record in the table that is Anaheim. Whatever team I'll write in my where conditions it will always be Anaheim. I would have no problem if i had just to say when its home or away but i cant do it like this. It has to be the most rencent game played.
Thanks for your help!