I'm trying to retrieve the last 3 dates in a table. I should be able to SORT BY Date DESC LIMIT 3, then resort the array (using I forget which PHP function) - right? - But I thought there might be a slicker way to just do it in SQL - the equivalent of LIMIT 3 but off the end of the result set instead of the beginning.
I suppose if I knew the number of records I could use that:
LIMIT [count-3], [count]
Hmm - maybe I should try my first subquery. Gotta check if my client's host is SQL 4.1+...
Maybe something like:
LIMIT ((SELECT COUNT() FROM Dates) -3), (SELECT COUNT() FROM Dates)
...nope, that just blows up.
Any advice?