I have a database with users and notes related to each user in a one to many relationship.
I want to make a query which returns the details of the users including the last note which was made about them.
To illustrate here's an example of the data:
So for user David the note included in the results should be note.id=6 and for John note.id=3 for instance.
SELECT user.firstname,
user.lastname,
note.note
LEFT JOIN note
ON note.userID = user.id
What can I add to this SQL query to only include the last added note for each user?