我在获取列的总和时遇到问题。
它会像SUM('billing_amount' - billing_philhealth)
我尝试了以下代码但没有解决问题...
<?php
$this->db->where('billing_id', $data->billing_id);
$this->db->select_sum(('billing_amount') - ('billing_philhealth'));
$query3 = $this->db->get('billing_entry');
$x = 1;
foreach ($query3->result() as $tot)
{
echo '<h3>₱'.$tot->billing_amount.'</h3>';
echo '<input type="hidden" name="total_amount" id="totAmt" value="'.$tot->billing_amount.'">';
}
?>
答案 0 :(得分:2)
试试这个
$this->db->select('SUM(field1) + SUM(field2) + SUM(field3) as total', FALSE);
FALSE停止自动转发