0

次のクエリは、recipecomments.RecipeID が表示されるたびにレコードを取得します。レシピ ID ごとに 1 つのレコードを取得したいのですが、レシピ ID によるグループ化は機能していないようです

SELECT recipecomments.RecipeID
      ,recipecomments.CommentID 
      ,recipes.RecipeID
      ,recipes.Name
      ,recipes.CategoryID
      ,recipes.RatingTotal
      ,recipes.ImageMed
FROM recipecomments 
     JOIN recipes ON recipecomments.RecipeID = recipes.RecipeID                 
ORDER BY recipecomments.CommentID
4

1 に答える 1

1

レシピ ID でグループ化する場合は、表示する CommentID を決定する必要があります。あなたの構文から、私は最高だと思います。

 SELECT 
      recipecomments.RecipeID,
      MAX(recipecomments.CommentID),
      recipes.RecipeID,
      recipes.Name, 
      recipes.CategoryID,
      recipes.RatingTotal,
      recipes.ImageMed
 FROM recipecomments   
                JOIN recipes ON recipecomments.RecipeID = recipes.RecipeID 
 group by 
      recipecomments.RecipeID,
      recipes.RecipeID,
      recipes.Name, 
      recipes.CategoryID,
      recipes.RatingTotal,
      recipes.ImageMed
于 2012-08-20T13:55:14.653 に答える