I have a games table, schema:
gameid int(11)
gamenum int(11)
gamedate datetime
homescore int(11)
visitorscore int(11)
homeid int(11)
visitorid int(11)
fieldid int(11)
Now I need to get a team's (homeid or visitorid) last five games
with unreported scores (homescore and visitorscore is null)
before now.
What SQL would return that?
{$teamid will be passed in the function}
select * from games
where (homescore is null and visitorscore is null) and
((homeid = $teamid) or (visitorid = $teamid)) and
(gamedate < now) // This is the part I need...