I have two tables named foo
and bar
, hypothetically speaking.
foo has columns foo_id
, foo_fluff
bar has columns bar_id
, foo_id
, timestamp
I need a query which will retrieve return one row for any foo_id that the table bar contains, with the latest timestamp.
So, if bar has three rows, two of which have a foo_id of 1, and 1 of which has foo_id 2, it'll return 2 rows. For foo_id 1 it'll return the row which has the greater timestamp of the two rows.