Reputation: 1702
I have three tables in database tbProduct, tbCompany, tbCompanyProduct
tbProduct
tbCompany
tbCompanyProduct
Now I have to perform join operation for fetching all the products assigned to a company i.e on the basis of @companyid parameter... Please help me !!!
Upvotes: 0
Views: 48
Reputation: 425
Your query will look like this.....It is simple join between three tables...
SELECT comp.CompanyName, prod.ProductX
FROM tbCompanyProduct compPro
INNER JOIN tbCompany comp ON compPro.Company = comp.CompanyId
INNER JOIN tbProduct prod ON prod.Product = compPro.Product
WHERE comp.CompanyId = yourCompanyId
Upvotes: 2