Here there,
Is there anyway of shortening this MySQL query at all??? It needs to grab two diffrent rows from the PriceRuleDetail table from the column called RuleValue based on it's price rule, but using an Alias, have them returned in the same row. It's using subqueries inside the select statement, which I assume is right, but there may be an easier way?
The below does work correctly and i'm reasonably happy with it, but I was wondering if there was a way of making this shorter???
SELECT Stock.*,
(SELECT PriceRuleDetail.RuleValue
FROM PriceRuleDetail
WHERE PriceRuleDetail.Sku = Stock.Sku
AND PriceRuleDetail.PriceRule = 'RG'
AND PriceRuleDetail.Quantity = 1) as Price,
(SELECT PriceRuleDetail.RuleValue
FROM PriceRuleDetail
WHERE PriceRuleDetail.Sku = Stock.Sku
AND PriceRuleDetail.PriceRule = 'RRP'
AND PriceRuleDetail.Quantity = 1) as WasPrice
FROM Stock, StockCategoryMemberList
WHERE StockCategoryMemberList.Sku = Stock.Sku
AND StockCategoryMemberList.CategoryCode = 'FIRE'
Thanks in advance.
Andy