I have a products table…
alt text http://img357.imageshack.us/img357/6393/productscx5.gif
and a revisions table, which is supposed to track changes to product info
alt text http://img124.imageshack.us/img124/1139/revisionslz5.gif
I try to query the database for all products, with their most recent revision…
select * from `products` as `p` left join `revisions` as `r` on `r`.`product_id` = `p`.`product_id` group by `p`.`product_id` order by `r`.`modified` desc
but I always just get the first revision. I need to do this in one select (ie no sub queries). I can manage it in mssql, is this even possible in mysql?
Here’s how I’d do it:
In other words: find the revision for which no other revision exists with the same product_id and a greater modified value.