我制作了一个小型修订系统,每次修改时都会存储文本的新版本。
该表如下所示:
+-------+-----+----------+
| revID | nID | text |
+-------+-----+----------+
| 1 | 1 | foo |
+-------+-----+----------+
| 2 | 1 | newfoo |
+-------+-----+----------+
| 3 | 2 | bar |
+-------+-----+----------+
| 4 | 2 | baz |
+-------+-----+----------+
| 5 | 3 | a |
+-------+-----+----------+
什么 SQL 语句会给我每个 nID 的最后插入的行?像这样:
+-------+-----+----------+
| revID | nID | text1 |
+-------+-----+----------+
| 2 | 1 | newfoo |
+-------+-----+----------+
| 4 | 2 | baz |
+-------+-----+----------+
| 5 | 3 | a |
+-------+-----+----------+