I'm trying to SELECT the most recent record in a table for each person record in another table. Here's what I have so far:


SELECT
        history.*,
        persons.person_short_name,
        persons.person_long_name
        
FROM
        history, persons
                
WHERE
                persons.id = history.person_id
        AND persons.status = 1
        
GROUP BY history.person_id                      
ORDER BY history.time_sec DESC



The good thing: It retrieves DISTINCT persons (no duplicates).
The problem: The history rows are not the most recent for each person. What I would need, theoretically, is for the ORDER BY clause to go before GROUP BY, but MYSQL doesn't like that it seems.

Any ideas?

Thanks.

...René

---
René Fournier
www.renefournier.com

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to