0
我無法在計算列上寫入條件。我已經閱讀了Stackoverflow上的一篇文章。不幸的是,我仍然無法弄清楚。我有以下MySQL查詢:在計算列上使用子句WHERE(包括子查詢)
SELECT
c.pk_tbl_commodity, c.s_name, c.s_default_variant,
p.pk_tbl_parameter, p.s_name_parameter,
((SELECT SUM(p2.n_price_parameter) from tbl_Parameter p2
WHERE p2.fk_tbl_commodity = p.fk_tbl_commodity
AND p2.b_default = 1
AND p2.s_name_parameter <> p.s_name_parameter GROUP BY NULL) + c.n_price_without_dph + p.n_price_parameter) as total
FROM tbl_Commodity c JOIN tbl_Parameter p on (p.fk_tbl_commodity = c.pk_tbl_commodity)
WHERE s_name like '%acti%'
AND b_bin = '0'
AND total = 3340
ORDER BY s_name, s_default_variant;
我得到了錯誤:
[Err] 1054 - Unknown column 'total' in 'where clause'
我怎麼能在子查詢和總和(列別名總)的結果添加條件?
謝謝。