I have this query, in addition to other PHP code:
select g.gamenum,
g.gamedate,
g.homeid,
h.teamname home,
g.homescore hscore,
g.visitorid,
v.teamname visitor,
g.visitorscore vscore
from games g,
teams v, teams h
where (g.homeid = h.id and g.visitorid = v.id)
and (WEEK(g.gamedate) = '.gmstrftime ("%W", time()-18000).')
and ( g.homescore is not null and g.visitorscore is not null )
and (h.division = "A" or v.division = "A")
order by gamedate
This query never works on Mondays when I need to return the
games that were played the previous weekend (Sat/Sun) .
What do I need to change to get it to work correctly and return
the games played the previous weekend if it is a Monday.
If it is any other day than Monday, it needs to return all games
played during the same week.
PHP can be used to build that part of the where clause.