PROBLEM: I'm trying to pull a list of all records, DISTINCT
by the Name using the highest Added timestamp number for that name. I use all results columns in a PHP fetch
.
Have a simple database with records as follow:
---ID-------NAME-------VERSION-----------ADDED-------
| 500 | TheSame | 1 | UNIX_TIMESTAMP() |
| 501 | TheSame | 2 | UNIX_TIMESTAMP() |
| 502 | SameName | 30 | UNIX_TIMESTAMP() |
| 503 | SameName | 31 | UNIX_TIMESTAMP() |
-----------------------------------------------------
ID
is auto-increment. Tried a ton of different things and can get the DISTINCT
or GROUP BY
to work fine, but I end up with the lowest record (ex: SameName
record #502 and version #30, when it should be #503 and version #31.
No JOIN
or anything going on here, so this should be pretty simple.