On 10/16/06, kalin mintchev <[EMAIL PROTECTED]> wrote:
> > but that will get you all records for that category not just the most > recently updated. > that's the main problem, isn't it? what i'm looking for is the last record for EACH of the categories in the table. i'm aware of the aformentioned options. my problem with group by is that ignores the DESC in order by. if i do: select id from table group by category; it does the same as if i do: select id from table group by category order by id desc; both queries return the FIRST found record for EACH category in ascending order - the order they were indexed in. i geuss i still don't get why if i request 'order by id desc' the 'group by' doesn't look 'backwards'. obviuosly the 'grouping' comes before the 'ordering' in the query - it probably is executed that way too. why can't it be the other way around taking in consideration the request of ordering the results in descending order and then grouping them by category....
The "order by" orders the *results* of the group by. It does not affect what happens inside the group by. This is standard across all databases - mysql, postgres, sqlite - all of them. It can't be done the other way because grouping the results together will affect ordering (think of aggregate functions especially). -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]