I'm sure this one has been asked before but I can't find it in the
archives.
"How do I return the most recent row for a given xxx?"
+-----------------+---------------+------+-----+---------------------+
| Field | Type | Null | Key | Default |
+-----------------+---------------+------+-----+---------------------+
| Created | datetime | | | 0000-00-00 00:00:00 |
| UserID | int(11) | | PRI | 0 (auto increment) |
| UserName | char(64) | YES | | NULL |
+-----------------+---------------+------+-----+---------------------+
My gut feeling is this *should* work, but it doesn't, it always returns
"Empty set (0.08 sec)"...
select
UserName, Created, max(Created) as Latest
from
MyTable
where
UserName = 'MyUserName'
group by
UserName
having
Created = Latest;
I should know this but keep coming up blank, your help would be
most appreciated...
--
If it ain't opinionated, it ain't Rich Teer.