gpt4 book ai didi

mysql - 这个 SQL 查询有什么问题

转载 作者:行者123 更新时间:2023-11-29 05:27:49 26 4
gpt4 key购买 nike

这个查询给我错误,请问这个查询有什么问题?

SELECT recipes.recipeId as recipeId,
recipes.title as title,
recipes.cookingtime as cookingtime,
recipes.serving as serving,
schedule.catId as catId,
images.imagePath AS imagePath
FROM recipes
INNER JOIN schedule ON recipes.recipeId = schedule.recipeId
INNER JOIN images ON images.recipeId = recipes.recipeId
GROUP BY recipeId
WHERE schedule.day = 'saturday'
ORDER BY catId ASC

我觉得查询中group by的位置不对。

最佳答案

你的想法是正确的。 GROUP BY 应该在 WHERE 子句之后和 ORDER BY 子句之前。

SELECT recipes.recipeId as recipeId,
recipes.title as title,
recipes.cookingtime as cookingtime,
recipes.serving as serving,
schedule.catId as catId,
images.imagePath AS imagePath
FROM recipes
INNER JOIN schedule ON recipes.recipeId = schedule.recipeId
INNER JOIN images ON images.recipeId = recipes.recipeId
WHERE schedule.day = 'saturday'
GROUP BY recipeId
ORDER BY catId ASC

关于mysql - 这个 SQL 查询有什么问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18032494/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com