如何将这些查询组合在一起作为一个结果

How to combine these queries together as one result

SELECT COUNT(recipe_id) AS Found
FROM recipe_ingredients R, users_ingredients U
WHERE R.key_ingredient = U.key_ingredient;

SELECT recipe_id, COUNT(recipe_id) As Count FROM recipe_ingredients GROUP BY recipe_id;

根据您的评论,我了解到您需要显示三列 recipeId, foundIngredients, countIngredients

由于没有 table 模式,我假设了结构并派生了以下查询:

SQL Fiddle 是 http://sqlfiddle.com/#!9/eee151/3

SELECT COU.recipe_id, IFNULL(FOU.Found, 0) AS Found, COU.Count
FROM  ( SELECT recipe_id, COUNT(recipe_id) As Count 
        FROM recipe_ingredients 
        GROUP BY recipe_id) COU
LEFT OUTER JOIN ( SELECT R.recipe_id, COUNT(R.key_ingredient) AS Found
        FROM users_ingredients U
        JOIN recipe_ingredients R ON R.key_ingredient = U.key_ingredient
        GROUP BY R.recipe_id) FOU ON FOU.recipe_id = COU.recipe_id