On this question I received an answer that worked well. I am now wondering if there is a possible better structure.
I have two tables.
Projects : id, title
Status : project_id, status_id, created(DATETIME)
At the moment to get the status of my project, I get the project ID and pull the latest row out of the status table based on the project id. To get this latest row is quite a hassle.
Should I rather change the schema to this?
Projects : id, title, current_status_id(FK)
Status : id(PK), project_id, status_id, created(DATETIME)
Then I can just join the tables with the FK and get the row that I want without looking for the latest?
EDIT:
So I want something like this
SELECT * FROM projects
LEFT JOIN status on projects.id = status.project_id
WHERE projects.id = 1
But I want only the latest record in the status table.
EDIT 2:
So I want something like this
SELECT * FROM projects
LEFT JOIN status on projects.id = status.project_id
But for each project returned, only get the latest status record for that project_id from status.