Hi Paul, Me> I think that the command "SELECT id, ref, MAX(timestamp), field FROM t Me> GROUP BY ref;" should give me fields with the latest timestamp for Me> each ref in my table. But it doesn't.
Paul> 1) Why do you think that query should return that result? Apparently because I had some misunderstanding of the GROUP BY semantics. I was assuming that "GROUP BY ref" would give me the ref and the field that were associated with the MAX(timestamp). Paul> 2) Why are you selecting the id value? Paul> In other words, remove id from the query and see what happens. I didn't need to. All I really need is the ref and the field. Here is the same SELECT without the id. mysql> select ref, max(timestamp), field from t group by ref; +-----+------------------+---------------+ | ref | max(timestamp) | field | +-----+------------------+---------------+ | 1 | 2002010814:59:34 | 1 version one | | 2 | 2002010814:59:34 | 2 version one | +-----+------------------+---------------+ 2 rows in set (0.00 sec) It gives the same result --- the ref and the field are not those from the same row as the max(timestamp). Dave --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php