I have 2 relevant tables here, application
and application_note
.
I want to find the latest note (user and text/note) for each application.
application_note
looks like
+----------------+-------------+------+-----+-------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+-------------+------+-----+-------------------+-----------------------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| create_time | timestamp | NO | | CURRENT_TIMESTAMP | |
| update_time | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
| application_id | int(11) | YES | MUL | NULL | |
| note | text | YES | | NULL | |
| user | varchar(50) | YES | | NULL | |
+----------------+-------------+------+-----+-------------------+-----------------------------+
I've been trying a bunch of different queries. The closest thing I have is
SELECT user, note, application_id, MAX(create_time)
FROM application_note
GROUP BY application_id
which looks like the max(create_time) is what I expect, but the other values are off. I've been trying at this for awhile and have been getting no where.
edit: I plan to eventually add this a view or add this to a larger query, if that changes anything.