I have a table named mip. The table has primary key id
, a foreign key product_id
and a column usage_type
. product_id
is a primary key id
to a table named product
.
It is one to many relationship from product to mip table (so a single product can have many mip).
I want to know all the products which have more than one mip rule with different usage type.
Could you please help me write the query ?
This is what I have written so far:
select count(product_id)
from mip, product
where product.id = mip.product_id
group by product_id
having count(mip.id > 1)