【发布时间】:2019-05-29 00:45:12
【问题描述】:
我有一个递归查询
With RECURSIVE tree AS
(
SELECT * FROM comments WHERE id = 83
UNION
SELECT t.*
From comments t
JOIN tree rt ON rt.parent_id = t.id
)
SELECT * from tree ORDER BY id DESC LIMIT 5
如何通过 ASC 再订购一次?
Edit1: 尝试了这个解决方案: Get the last N rows in the database in order?
With RECURSIVE tree AS
(
SELECT * FROM comments WHERE id = 83
UNION
SELECT t.*
From comments t
JOIN tree rt ON rt.parent_id = t.id
)
select * from (SELECT * from tree ORDER BY id DESC LIMIT 5) order by id
给我一个错误:
ERROR: subquery in FROM must have an alias
【问题讨论】:
-
你能解释一下想要的顺序是什么吗?
-
我尝试了那个解决方案,但它不起作用,这就是我发布的原因
标签: sql postgresql sql-order-by