I'm have a MySQL 5.1 DB with this table (paraphrasing)...
contracts
---------
id
parent_id
end_date
So contracts can have parent-child relationships via parent_id, and there can be several levels of nesting.
Given some contract with an id of let's say 1, how can I write a query to find the last end_date among it and its descendants?
(It would also be great to get the ids of the contract(s) with that end_date.)
 
    