Try something like this: SELECT USERS.Username,FILES.Filename FROM USERS LEFT JOIN FILES USING(Id) WHERE FILES.Filename IS NOT NULL ORDER BY FILES.Stamp DESC LIMIT 1;
If Filename declared as NOT NULL then use FILES.Filename!='' MR> I've been racking my brain for too long on this one, can someone help me MR> out with a SQL query? MR> I've got 2 tables in a mySQL database, 'users' and 'files' defined as MR> such: MR> USERS MR> ------------------- MR> Id int (autoincrement) MR> Username varchar MR> FILES MR> ------------------- MR> Id int (autoincrement) MR> Userid int MR> Stamp int (holds unix_timestamp for MR> filectime($filename)) MR> Filename varchar MR> What I want is a single query that returns all of the users that have MR> submitted files, and only the MOST RECENT file for each user. I'm sure MR> I need a GROUP BY and/or a MAX() in there somewhere..... -- Best regards, Evgeny mailto:[EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php