In a sqlite database i have a "Users" table as follows
Users:
| user_id | user
| 1 | John
| 2 | Peter
a "Posts" table as follows:
| post_id | user_id | text
| 10 | 1 | blah blah blah
| 11 | 1 | blah blah blah
| 12 | 2 | blah blah blah
I'm using this code to join two tables:
SELECT * FROM Users JOIN Posts USING ( user_id )
Now i have a list of all posts by different users as follows:
| user_id | user | post_id | text
| 1 | John | 10 | blah blah blah
| 1 | John | 11 | blah blah blah
| 2 | Peter | 12 | blah blah blah
Assuming that the post with bigger post_id is posted more recently.
Now i want a list of most recent posts by each users (row #2 and #3 in this case).
How can i do this?
I'm thinking of deleting all rows (for each users) , except the rows which has biggest post_id (most recent), is this a good solution? how should i query it?