查询为:
SELECT prd.*,
CASE
WHEN pr.type = 1 THEN Round(prd.price - ( prd.price * pr.value / 100 ),
2)
WHEN pr.type = 2 THEN Round(prd.price - pr.value, 2)
ELSE Round(prd.price, 2)
END promo_price
FROM product AS prd
LEFT JOIN promotion_product AS prPrd
ON prd.id = prPrd.main_product_id
LEFT JOIN promotion AS pr
ON prPrd.promo_id = pr.id
WHERE prd.category_id = 8
AND promo_price BETWEEN 46.15 AND 75.60
ORDER BY sort ASC
我收到错误消息:Unknown column 'promo_price' in 'where clause'
。这是为什么 ?我尝试用as
加上括号,用as
加上括号。我以前使用过这样的语法。我现在的错误在哪里?