I am getting:
#1064 - You have an error in your SQL syntax. Check the manual that
corresponds to your MySQL server version for the right syntax to use near
'SELECT max( yearmonth )
FROM periods )
ORDER BY mr.currentra
With this query:
select b.boatname, mr.currenttcf, mr.startingtcf, mr.averagetcfformonth,
mr.totalraces, mr.racesinmonth,
mr.currentranking, mr.startofmonthranking, mr.rankingchangeinmonth,
design
from MonthlyRankings mr, boat b
where mr.boatid = b.boatid
and mr.yearmonth = (select max (yearmonth) from periods)
order by mr.currentranking
It works fine if I remove:
and mr.yearmonth = (select max (yearmonth) from periods)
It also works if I change it to:
and mr.yearmonth = '2004-11-01'
And this works by itself, and returns '2004-11-01':
select max (yearmonth) from periods
So, it makes no sense to me that the syntax is invalid, any ideas?