going crazy over here!!!

If you will notice in the bottom left hand corner the ProductCategoryName Column is producing two and three results on the same product and these products are not in the categories table, this categories table is where the ProductCategoryName is at so i am not sure what is going on here.

I am including a photo on a url so that you may have a look at the web site.

http://afcc1.com/sqlHELP

==============================================
I NEED the ProductID , ProductCategoryName , and the CompanyID

WHERE the companyid = @idcompany

and Categories.Productcategoryid = 20 (0r something like this)
=============================================

I need someone who has knows sql to take a peek at this and let me know what i need to add or do to receive the proper result.
Thank you!

http://afcc1.com/sqlHELP

Erik

Ok...

SELECT CompanyName, CompanyID, ProductCategoryName, ProductID
FROM Company C 
		 JOIN Product P ON C.CompanyId = P.CompanyId
		 JOIN Category CA ON CA.ProductId = P.ProductID
WHERE C.CompanyID = 16 AND P.ProductID = 20
ORDER BY C.CompanyName

(16 and 20 where just arbitrary numbers I used)

That should work. Now saying that you have your middle table (Product) not quite right. In a Normalized DB you would have CompanyID, ProductID, and ProductCategoryID as your Primary Keys for that table. (See Sales <-- Stores --> Discounts in the Pubs database in SQL for what I mean).

Hope this helps

Oh by the way! Fantastic Request for Help Post!

<<ANYONE asking a question or asking for Help...follow this thread as an example of how to ask that question or for help >>

:D:D:D:D:D:D:D:D:D

going crazy over here!!!

If you will notice in the bottom left hand corner the ProductCategoryName Column is producing two and three results on the same product and these products are not in the categories table, this categories table is where the ProductCategoryName is at so i am not sure what is going on here.

I am including a photo on a url so that you may have a look at the web site.

http://afcc1.com/sqlHELP

==============================================
I NEED the ProductID , ProductCategoryName , and the CompanyID

WHERE the companyid = @idcompany

and Categories.Productcategoryid = 20 (0r something like this)
=============================================

I need someone who has knows sql to take a peek at this and let me know what i need to add or do to receive the proper result.
Thank you!

http://afcc1.com/sqlHELP

Erik

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.