I'm trying to retrieve the most recently touched entries in a table using this SQL.
SELECT DISTINCT USERS.username AS uname FROM USERS, HITS WHERE USERS.userid = HITS.userid AND HITS.userid > 0 ORDER BY HITS.lasthit DESC LIMIT 5
But it's acting weird and not showing what I think it would show. lasthit is a datetime field. I'm using the limit because I only want the last 5 people and there are some entries where the userid is 0 that I want to filter out. Any help?
My current results skip some entries that should be queried for some reason.
Thanks.