Complex query in Room android

旧街凉风 提交于 2020-01-06 07:53:29

问题


I am trying to use Room in my application but I have a very complex query that makes a recursive and inner join between multiple tables

here is my query,

fun test(categoryId: Int): String {

        return "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"
    }

this method supposes to return the query string and I have tested in mysql and it is working.

How to be able to convert this query to Room?

来源:https://stackoverflow.com/questions/54968989/complex-query-in-room-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!