我有这个问题:
WITH RECURSIVE cte(Id, Type, ParentId, CreationDate, SenderId, Message) AS
(
SELECT c.* FROM (SELECT Id, Type, ParentId, CreationDate, SenderId, Message
FROM GroupMessage
WHERE GroupId = '4a80590e-036c-45b6-a512-be0d8e48fbb6'
AND ParentId is NULL
ORDER BY CreationDate DESC
LIMIT 20 OFFSET 0) as c
UNION
SELECT c.Id, cte.Type+1, c.ParentId, c.CreationDate, c.SenderId, c.Message
FROM cte, GroupMessage c
WHERE c.ParentId = cte.Id AND c.Type = '1'
ORDER BY CreationDate DESC
)
SELECT * FROM cte
目前,我将父信息的数量限制为最近的20条。我怎么能把孩子的数量限制在最近的5或10个?我尝试在UNION ORDER BY之后添加LIMIT关键字,但整个查询只返回5或10行。此外,OPTION关键字在Sqlite3中不可用,而且我的想法已经用完了。