I imagine this has been done many time before but I can’t for the life of me figure it out and I am tired of trying work arounds.
I have two tables.
One is an Object having ObjectID(key), Name, Type, Location
Two is ObjectStatus having StatusID(key),ObjectID,Status,DateChanged,UserWhoChangedStatus
What I want to do is return all Objects and the ObjectStatus that was entered last
Table 1 Object
ObjectID Name Type Location
1 Blue Ball Ball ToyBox
2 Red Ball Ball ToyBox
Table 2 (ObjectStatus)
StatusID ObjectID Status DateChanged UserWhoChangedStatus
1 2 Broken 2012-01-25 56481
2 2 Fixed 2012-01-30 98526
3 1 Bouncy 2012-01-05 85245
4 1 Sticky 2012-02-10 56481
I would want to get returned
ObjectID Name Type Location StatusID Status DateChanged UserWhoChangedStatus
1 Blue Ball Ball ToyBox 4 Sticky 2012-02-10 56481
2 RedBall Ball ToyBox 2 Fixed 2012-01-30 98526
Which is all Objects and the ObjectStatus that was last entered
Since you didn’t say the DBMS I will assume Ms Sql Server.