Considering I have three tables:

* product
* shop
* supplier

and their junction tables:

* product\_shop
* product\_supplier

I am trying to get all products that are supplied by a specific supplier and available in multiple shops, i.e. all products from supplier A that are in shop 1 and 2. 

If we assume, supplier has 10 products, of which 5 are available in shop 1 and 7 are available in shop 2, but only 3 are available in shop 1 and 2, then those are the 3 I am seeking.

Here is what I have so far (in `postgresql 9.6`), which simulates an inclusive IN. Which works, but it doesn't seem right (proper) to me:

**edit:**
I use this query dynamically and have therefor to pass the list of shops (which varies), the supplier of course, and the count (which is equal to the length of the list of shops). It's not that this is a bother, but I was nonetheless wondering if there is a way to create a query using only joins.

```
 SELECT
    product_shop.product
FROM
    (SELECT product FROM product_shop where shop in (1, 2)) product_shop JOIN
    product_supplier ON product_shop.product = product_supplier.product 
WHERE
    product_supplier.supplier = A
GROUP BY
    product_shop.product
HAVING
    count(product_shop.product) = 2

```

Is there a better query to achieve the result I am seeking?

> 
> \*Not a native speaker
> 
> 
>