At 13:15 1999-04-29 +0200, Christian Mack wrote:
>[...suggested queries skipped...]
>Hi Robin
>
>This don't work, because MAX() is a group function, which can't be used in
>WHERE clauses (defined by SQL standard).
>
>Therefore it is impossible to get what Fred wants to get in one query.
Maybe I'm missing something, but "order by fieldname desc limit 1" usually
gets me the record where the field has the largest value (or smallest
without desc).
In this case:
select UserName, Created
from MyTable
where UserName = 'MyUserName'
order by Created desc limit 1
To simple to work? mySQL knows how to optimize this type of query.
Regards,
Erik L.
---
Erik Liljencrantz, E-ell-Data, http://www.eldata.se
erik@stripped, +46 150 250 58, +46 70 51 8 51 26
Aspenaes, 640 25 JULITA, SWEDEN