Query to filter products based on related table with multiple conditions

hi
i have a problem building a dynamic query with QueryBuilder to filter items based on multiple conditions on related table:

SELECT products.id
FROM products 
  INNER JOIN product_properties ON products.id = product_properties.product_id
  INNER JOIN properties ON properties.id = product_properties.property_id 
group by products.id
having sum(properties.name = 'lens_family' AND product_properties.value = 'Standard') > 0 and
   sum(properties.name = 'lens_mount' AND product_properties.value = 'F-Mount') > 0 and
   sum(properties.name = 'image_circle' AND product_properties.value >= ABS('40 mm')) > 0 and
   sum(properties.name = 'focal_length' AND product_properties.value >= 5) > 0;