Here is the table structure:
+----+-----------------------------+-----------+
| id | post_content | edited_id |
+----+-----------------------------+-----------+
| 1 | content 1 | NULL |
| 2 | content 2 | NULL |
| 3 | content 1 (edited) | 1 |
| 4 | content 3 | NULL |
| 5 | content 4 | NULL |
| 6 | content 4 (edited) | 5 |
| 7 | content 1 (edited) | 1 |
+----+-----------------------------+-----------+
Now I want to select the latest edited version of each post. So this is expected result:
+----+-----------------------------+-----------+
| id | post_content | edited_id |
+----+-----------------------------+-----------+
| 7 | content 1 (edited) | 1 |
| 2 | content 2 | NULL |
| 4 | content 3 | NULL |
| 6 | content 4 (edited) | 5 |
+----+-----------------------------+-----------+
How can I do that?