gpt4 book ai didi

Mysql,加入查询,一头雾水

转载 作者:可可西里 更新时间:2023-11-01 08:20:51 26 4
gpt4 key购买 nike

我面临的问题是,我想加入这两个查询。

   SELECT recipes.RecipeID ,recipes.Name,recipes.ImageThumb,recipes.RatingTotal,
count(ratings.RecipeID) AS trates
FROM recipes
JOIN ratings
ON ratings.RecipeID = recipes.RecipeID
WHERE recipes.Name LIKE '%ade%'
ORDER BY Name;

这个查询没有按预期工作,当有多个结果时它会带来 1 个结果,并且比率是所有结果的总和,而不仅仅是那个特定的 RecipeID

最佳答案

我想这就是您要找的:

SELECT recipes.RecipeID ,recipes.Name,recipes.ImageThumb,recipes.RatingTotal,
COUNT(ratings.RecipeID) AS trates
FROM recipes
LEFT JOIN ratings
ON ratings.RecipeID = recipes.RecipeID
WHERE recipes.Name LIKE '%ade%'
GROUP BY RecipeID
ORDER BY Name;

关于Mysql,加入查询,一头雾水,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11792733/

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