我有一个名为POTION_INGREDIENTS的表的简单数据库。
此表包含POTION_CODE,INGREDIENTE_CODE和QUANTITY字段以创建配方。
我想为POTION_CODE等于C1和C2的药水找到常见的INGREDIENTES。
我正在尝试以下查询,但这不起作用:
SELECT
INGREDIENT
FROM
POTION_INGREDIENTS
WHERE
POTION_CODE='C1' OR
POTION_CODE='C2'
HAVING COUNT(INGREDIENTE) > '1'
此致
答案 0 :(得分:0)
尝试:
SELECT INGREDIENT
FROM POTION_INGREDIENTS
WHERE POTION_CODE IN ('C1','C2')
GROUP BY Ingredient
HAVING COUNT(INGREDIENT) > 1
答案 1 :(得分:0)
尝试使用
select ingredient,
count(ingredient)
from potion_ingredients
where potion_code = 'C1'
or potion_code = 'C2'
group by ingredient
having count(ingredient) > 1