0
我有一个简单的版本控制系统的博客系统。我的DB是:得到子查询并计为colomn
|id------|parent_id|title------------------|
|1 |1 |Test title |
|2 |1 |Test title 2 |
|3 |1 |Last test title |
|4 |4 |Another blog item |
我的查询只得到最新的版本(仅3和4):
SELECT * FROM
(SELECT * FROM blogs ORDER BY id DESC) b
GROUP BY b.parent_id
结果:
- 最后测试题
- 另一个博客item
我的问题是:是可以统计的所有子版本的数量?这样的:
- 最后测试题(3)
- 另一个博客项(1)
是的,这是可能的。 – hjpotter92