user5423926
user5423926

Reputation:

How to select only value greater than 0?

In my query I want to discard the values equals to 0, actually this is my query:

$query = $this->db->select('GroupID')
                  ->group_by('GroupID') 
                  ->from('ea_appointments')
                  ->where('id_users_provider', $record_id)
                  ->get()->result_array();

how you can see this query return only the GroupID value not equals so if I've:

0 - 0 - 1 - 1 - 2

(as GroupID).

I get only:

0 - 1 - 2

now I want to get only the value greater than 0, so thr query should be return this:

1 - 2

how I can achieve that in CodeIgniter?

Upvotes: 0

Views: 106

Answers (1)

iam-decoder
iam-decoder

Reputation: 2564

just add a where statement for the GroupID and include the > symbol at the end of the column name like so:

$query = $this->db->select('GroupID')
              ->group_by('GroupID')
              ->from('ea_appointments')
              ->where('id_users_provider', $record_id)
              ->where('GroupID >', 0)
              ->get()->result_array();

Upvotes: 3

Related Questions