如果另一列为1或2,如何减去同一列
->from('product', array('SUM(weight)')
->where('store = 1')如果存储设置为2,则应始终减去权重值。
发布于 2015-07-15 23:17:25
如果可以的话试试这个..。
$selectCounting = $productsTable->select();
$selectCounting ->from('product',
array('SUM(IF(store = 2, 0, weight)) AS `totalweight`',
'product',
'weight'))
->where ('1=1')

https://stackoverflow.com/questions/31441852
复制相似问题