这是表结构:
+----+-----------------------------+-----------+
| 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 |
+----+-----------------------------+-----------+
现在我想选择每篇文章的最新编辑版本。所以这是预期的结果:
+----+-----------------------------+-----------+
| id | post_content | edited_id |
+----+-----------------------------+-----------+
| 7 | content 1 (edited) | 1 |
| 2 | content 2 | NULL |
| 4 | content 3 | NULL |
| 6 | content 4 (edited) | 5 |
+----+-----------------------------+-----------+
我怎样才能做到这一点?