我的目标:显示提交了最多食谱的用户。
假设我有一个名为Recipe的表,其中包含以下属性:
-- -----------------------------------------------------
-- Table `myDB`.`Recipe`
-- -----------------------------------------------------
recipeName
servingSize
submittedBy
userRating
submittedBy引用另一个名为User的表,列出了几个用户名。
这是我到目前为止所做的:
SELECT submittedBy
FROM Recipe
WHERE COUNT(submittedBy) =
(
SELECT
/*I am not quite sure how to go on from here*/
);
任何想法都将不胜感激。谢谢!
答案 0 :(得分:0)
尝试以下查询:
SELECT submittedBy, COUNT(1) AS count
FROM Recipe
GROUP BY submittedBy
ORDER BY count DESC
LIMIT 1