I have two tables, one that holds the equipment, and one that keeps track of the history of that equipment.
Each time something happens to a piece of equipment, a history entry is recorded. Meaning, the unique id of the equipment, is placed in the history table, along with time/date stamp, and WHAT exactly happened.
Here is an example of what I'm talking about:
Code: Select all
EQUIPMENT TABLE:
id name
8 Toshiba Laptop
HISTORY TABLE
id machine_id Action
89 8 Assigned to user John
90 8 Placed on shelf after John's departureI want to select ALL peices of equipment, and only the LATEST history item. (if it exists) In this case, where history.id = 90
The query I'm using is much more complicated than this, but this is the section which I'm having problems with. If you need more, let me know.
Thanks for any help guys and gals
--Cheers
