As far as I know, MAX only returns the greatest row, so what you really
want at the end is
WHERE table_tmp.id=table2.id AND table2.timestamp=MAX(table2.timestamp)
~MJI
Roy Walker wrote:
> Still having a problem with this. Still have one last thing that isn't working.
> This is MySQL 4.0.13.
>
> UPDATE table_tmp,table2_daily SET table_tmp.period_count = table_tmp.count -
> table2.count WHERE table_tmp.id = table2.id AND MAX(table2.timestamp);
>
> This is giving me:
> ERROR 1111: Invalid use of group function.
>
> I am trying to update the period_count field for all the records in table_tmp, by
> setting the equal to the count from table_tmp MINUS the count from table2 where the id's
> match and it is the newest record in table2.
>
> Any ideas?
> Please don't tell me to how to do it 4.1! Please! :)
>
> Roy
>

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.