MYSQL - Join most recent matching record from one table to another
问题 I have two tables that look like this: Table: cases id name status case_no Table: notes id case_id note_date notes I'd like to be able to create a query that grabs the data from the cases table and only the most recent entry from the notes table for each row in the cases table. So far I'm having no luck at all. Any pointers would be greatly appreciated 回答1: This will return only the cases with notes attached: SELECT c.*, x.* FROM CASES c JOIN NOTES x ON x.case_id = c.case_id JOIN (SELECT n