问题描述
SELECT *
FROM
(SELECT ROW_NUMBER() OVER (PARTITION BY recipe_name) AS rn,rt.*
FROM SyncRecipeIngredientTable sr
JOIN RecipeIngredientTable ri
ON ri.recipe_ingredient_id = sr.recipe_ingredient_id
JOIN RecipeTable rt
ON rt.recipe_id = sr.recipe_id
WHERE ri.recipe_item_name in ("ayva","su","pirinç")
GROUP by
rt.recipe_id HAVING COUNT(*) >= 3)
WHERE rn = 1
它可以像预期的那样在那里很好地工作。但是,当我将此代码块移动到如下所示的Flutter的sqflite上时:
List<Map<String,dynamic>> foundRecipeList = await db.rawQuery("""
SELECT *
FROM
(SELECT ROW_NUMBER() OVER (PARTITION BY recipe_name) AS rn,rt.*
FROM SyncRecipeIngredientTable sr
JOIN RecipeIngredientTable ri
ON ri.recipe_ingredient_id = sr.recipe_ingredient_id
JOIN RecipeTable rt
ON rt.recipe_id = sr.recipe_id
WHERE ri.recipe_item_name in ($finalStr)
GROUP by
rt.recipe_id HAVING COUNT(*) >= 3)
WHERE rn = 1
""");
这给我带来了一个问题:
I/Flutter ( 7208): AsyncSnapshot<dynamic>(ConnectionState.waiting,null,DatabaseException(near "(": Syntax error (code 1):,while compiling: SELECT *
I/Flutter ( 7208): FROM
I/Flutter ( 7208): (SELECT ROW_NUMBER() OVER (PARTITION BY recipe_name) AS rn,rt.*
I/Flutter ( 7208): FROM SyncRecipeIngredientTable sr
I/Flutter ( 7208): JOIN RecipeIngredientTable ri
I/Flutter ( 7208): ON ri.recipe_ingredient_id = sr.recipe_ingredient_id
I/Flutter ( 7208): JOIN RecipeTable rt
I/Flutter ( 7208): ON rt.recipe_id = sr.recipe_id
I/Flutter ( 7208): WHERE ri.recipe_item_name in ('su','pirinç','ayva')
I/Flutter ( 7208): GROUP by
I/Flutter ( 7208): rt.recipe_id HAVING COUNT(*) >= 3)
I/Flutter ( 7208): WHERE rn = 1
I/Flutter ( 7208): #################################################################
I/Flutter ( 7208): Error Code : 1 (sqlITE_ERROR)
I/Flutter ( 7208): Caused By : sql(query) error or missing database.
I/Flutter ( 7208): (near "(": Syntax error (code 1):,rt.*
I/Flutter ( 7208): FROM SyncRecipeIngredientTable sr
I/Flutter ( 7208): JOIN RecipeIngredientTable ri
I/Flutter ( 7208): ON ri.recipe_ingredient_id = sr.recipe_ingredient_id
I/Flutter ( 7208): JOIN RecipeTable rt
I/Flutter ( 7208): ON rt.recipe_id = sr.recipe_id
I/Flutter ( 7208): WHERE ri.reci
我该如何解决?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)