擅长:python、mysql、java
<p>我不能告诉你,如何用python编写它,但是这里有sql,你需要它,我希望它会有所帮助</p>
<pre><code>select
ic.cocktail_id
from ing_in_cocktails ic
left join (
-- here are you ingredients, that you have to pass as parameters.
-- keep in mind, that they must be unique
select 1 as ing_id
union all select 2
union all select 4
) ing_p on ic.ing_id = ing_p.ing_id
group by ic.cocktail_id
having count(*) = count(ing_p.ing_id) -- just need to check here, that amount of ingredients in cocktail is equal to ingredients, you passed as parameters
</code></pre>