Skip to content

Les organizations par produit possédé

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
SELECT organization.id
FROM organization
LEFT JOIN organization_product_pivot ON organization_product_pivot.organization_id = organization.id
WHERE
    organization_product_pivot.product_code = 'EXAM' /** selon le produit **/
  AND (
    /** seulement celles qui possèdent les 3 produits **/
    SELECT COUNT(*)
    FROM organization_product_pivot
    WHERE organization_product_pivot.organization_id = organization.id
) = 3;

Keywords

select organization organization_product_pivot product_code