I need some help with an SQL query. Let me describe the scenario
I have three tables, dispensaries
, goods
and products
.
products
records has two fk
, good_id
and dispensary_id
that let me access from dispensaries to goods through products.
Also goods has an attribute called name
Now the situation i wanna resolve is the following:
For a provided set of goods names ([good_name1, good_name2, etc]
) i want to get all the dispensaries that has ALL the goods in the array ( the goods that matches with those names ).
Let me add an example:
good1 whose names is good_1 belongs to dispensary1
good1 whose names is good_1 belongs to dispensary2
good2 whose names is good_2 belongs to dispensary1
so i need to create an SQL query that with a provided array of goods [good1, good2]
returns the only the dispesary1
Thanks in advance.