I need to query the sql server where I have to "connect" inventory to the companies.
The stock has 'n' products attached to it, and these products have 1 category attached to it.
The company also has 'n' categories attached to it.
I need to select all stocks that have at least 1 product that category equals one of the company categories.
For example:
Stock 1
produto 1 - categoria: pedra
produto 2 - categoria: brita
produto 3 - categoria: areia
Company 1
categorias: concreto, pedra, cimento.
Company 2
categorias: cimento, tijolo.
In this case, only company 1 would view stock 1, since one of its categories hits the category of one of the products in the stock.
Category Category
IDCATEGORIA
NMCATEGORIA
Inventory table
IDESTOQUE
NMESTOQUE
Product Table
IDPRODUTO
IDESTOQUE
NMPRODUTO
IDCATEGORIA
Company Table
IDEMPRESA
NMEMPRESA
CompanyCategory table
IDEMPRESA
IDCATEGORIA
I hope I have been clear.
Thank you in advance.