I've been racking my brain for too long on this one, can someone help me out with a SQL query?
I've got 2 tables in a mySQL database, 'users' and 'files' defined as such: USERS ------------------- Id int (autoincrement) Username varchar FILES ------------------- Id int (autoincrement) Userid int Stamp int (holds unix_timestamp for filectime($filename)) Filename varchar What I want is a single query that returns all of the users that have submitted files, and only the MOST RECENT file for each user. I'm sure I need a GROUP BY and/or a MAX() in there somewhere..... Maybe if I LEFT JOIN the table to itself........ Right now, I do one query for a list of users with files, then a separate query for each user to find their most recent file. It now takes in excess of 100 queries to build the page! There must be a better way. Thanks in advance for your help. Mike