PDA

View Full Version : I need a query to link ProductId to CategoryName for ps3


mulcare426901
06-09-2011, 11:28 AM
Hello I am using powerstore3.
I need to create a VIEW and export to CSV an output of a relation between my ps3_products.ProductID to the ps3_categories.CategoryID and ps3_categories.CategoryName. ...Now, the "ps3_productcategories table" has a ProductID.

I need to know how to write the "JOIN" or "what type of JOIN" in MySQL

It starting to look like spaghetti to me now.



So here goes, I have three tables......



1. ps3_categories [ CategoryID, CategoryName, CategoryParent ]


2. ps3_productcategories [ ProductCategoryID, CategoryID, ProductID ]


3. ps3_products [ ProductID, ProductName, ProductSKU, ...etc ]





I want to correllate the Product IDs ===>>> CATEGORY ID ===>>>>CATEGORY NAMES,



ANY help will be appreciated,

Regards

Jason Byrnes
06-09-2011, 12:56 PM
here ya go:


SELECT ps3_categories.CategoryName, ps3_products.ProductID, ps3_products.ProductName
FROM ps3_categories
INNER JOIN ps3_productcategories ON ps3_categories.CategoryID = ps3_productcategories.CategoryID
INNER JOIN ps3_products ON ps3_products.ProductID = ps3_productcategories.ProductID