是否可以在不使用实体的情况下使用Room运行SQLIte复杂查询?我只想运行一个复杂的递归查询,该查询返回所有实体ID的逗号分隔的字符串。
这是我的查询:
"WITH CTE AS (SELECT id, parent_id, id AS CategoryID FROM categories WHERE parent_id= 0 UNION ALL SELECT t.id, t.parent_id, t.id|| ', ' || CategoryID AS CategoryID FROM categories t INNER JOIN CTE c ON t.parent_id = c.id) SELECT CTE.CategoryID FROM CTE where CTE.id= " + categoryId + " ORDER BY CTE.id"
唯一的输出是categoryId
,然后查询应运行并返回不是实体的字符串