Khan Muntazar
Khan Muntazar

Reputation: 55

How can I give condition in where() function to get not equal to zero record in table

I have one Grand total column in my table and I want to show only greater then zero(0) number records in my table

I try like this in model

function fetchCashDetail($from_date_bk,$to_date_bk,$lr_pay_mode){

    $this->db->select('*')
          ->from('delivery_due_received')
          ->where('delivery_due_date BETWEEN "'. date('Y-m-d', strtotime($from_date_bk)). '" AND "'. date('Y-m-d', strtotime($to_date_bk)).'"');

    if($lr_pay_mode == 'pending'){ 
        $this->db->where('g_total !==0');
    }else{
        $this->db->where('pay_mode',$lr_pay_mode);
    }                                     
    return $this->db->get()->result();
}

And it returns Unknown column '=0' in 'where clause' this error message I want to show only greater then zero numbers.

Upvotes: 1

Views: 317

Answers (2)

Niranjan
Niranjan

Reputation: 45

$this->db->where('g_total >',0);

You can try this

Upvotes: 1

pr1nc3
pr1nc3

Reputation: 8338

$this->db->where('g_total != 0');

!== is not a valid expression

Or even better: $this->db->where('g_total !=', 0);

Upvotes: 2

Related Questions