Mysql intersect results

前端 未结 2 488
自闭症患者
自闭症患者 2021-01-21 13:56

I\'m trying to do something like the PHP array_intersect. I have the following table

CREATE TABLE `recipes_ingredients_items` (
  `id` INTEGER(11) D         


        
2条回答
  •  说谎
    说谎 (楼主)
    2021-01-21 15:02

    Try this:

    SELECT item_id
    FROM recipes_ingredients_items
    WHERE id IN (71, 2, 22)
    GROUP BY item_id
    HAVING COUNT(*) = 3
    

提交回复
热议问题