Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

PJijin's avatar

How to convert this sql query to Eloquent ORM.

SQL Query

SELECT v.product_id
  FROM (
      SELECT product_id, count(*) AS matches 
        FROM product where filter_id IN (2,4)
    GROUP BY product_id
  ) AS v
WHERE v.matches = 2

I want to convert this query to Eloquent ORM.

0 likes
2 replies

Please or to participate in this conversation.