I have 2 tables, 'users' and 'files' (defined below)

Can I construct a single SELECT statement so that it will return ONLY
users that have files and ONLY the last file that the user has?  So it
would return 1 row per user containing their most recent file.

users
--------
Id              int
Name            varchar

Files
--------
Id              int
Userid  int
Filename        varchar
Stamp           int             (unix_timestamp)

The way I'm doing it now, I use SELECT DISTINCT to get all the users
with files, then a separate query for each user returned to retrieve
their latest file.  This method requires many, many individual queries
to the database?

Any help is appreciated.

Thanks,
Mikey


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to