如果另一列为1或2
,如何从同一列中减去->from('product', array('SUM(weight)')
->where('store = 1')
如果存储设置为2,则应始终减去重量值。
答案 0 :(得分:1)
如果可以,请继续尝试...
$selectCounting = $productsTable->select();
$selectCounting ->from('product',
array('SUM(IF(store = 2, 0, weight)) AS `totalweight`',
'product',
'weight'))
->where ('1=1')