[PHP-DB] Re: SQL Troubles with JOIN, GROUP BY and MAX???

2002-06-04 Thread Evgeny Chuykov
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

Re: [PHP-DB] Re: SQL Troubles with JOIN, GROUP BY and MAX???

2002-06-04 Thread Hubert ADGIE
At 04/06/2002 08:58, Evgeny Chuykov wrote: 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; I think it's wrong because Id isn't the matching column in 'FILES'. 2nd line should be

[PHP-DB] Re: SQL Troubles with JOIN, GROUP BY and MAX???

2002-06-04 Thread Adam Royle
I think this is something like you would want... Adam SELECT users.id, username, MAX(stamp) as stamp, filename FROM users, files WHERE users.id = userid GROUP BY username -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php