Les organizations par produit possédé
| 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