MySQL Forums
Forum List  »  Newbie

SQL query for retrieving the right option price
Posted by: Steve Chance
Date: May 26, 2019 08:54AM

I am using the following query but it is not returning the right price for each option.

SELECT ProductName AS productname, ProductCategoryID,
pov.OptionGroupName AS groupname,
povd.OptionName AS optionname,
pd.OptionPrice as price

FROM products p
LEFT JOIN productoptions pd ON (p.ProductID = pd.ProductID)
LEFT JOIN optiongroups pov ON (pd.OptionGroupID = pov.OptionGroupID)
LEFT JOIN options povd ON (pov.OptionGroupID = povd.OptionGroupID)

LEFT JOIN productoptions price on pd.OptionID = povd.OptionID

WHERE p.ProductID = 1
GROUP BY groupname, povd.OptionName



RESULTS look like this (all prices should be different):

1 T-shirt 1 Color blue $2.20
2 T-shirt 1 Color green $2.20
3 T-shirt 1 Color red $2.20
4 T-shirt 1 Size L $5.55
5 T-shirt 1 Size M $5.55


Any help much appreciated!

Options: ReplyQuote


Subject
Written By
Posted
SQL query for retrieving the right option price
May 26, 2019 08:54AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.