Posts

Showing posts with the label Distinct

C# MongoDB Distinct Query Syntax

Answer : You could try the following approach: var filter = new BsonDocument(); var categoriesList = await blogContext.Articles.DistinctAsync<string>("categories", filter);

CodeIgniter: How To Do A Select (Distinct Fieldname) MySQL Query

Answer : $record = '123'; $this->db->distinct(); $this->db->select('accessid'); $this->db->where('record', $record); $query = $this->db->get('accesslog'); then $query->num_rows(); should go a long way towards it. You can also run ->select('DISTINCT `field`', FALSE) and the second parameter tells CI not to escape the first argument. With the second parameter as false , the output would be SELECT DISTINCT `field` instead of without the second parameter, SELECT `DISTINCT` `field` try it out with the following code function fun1() { $this->db->select('count(DISTINCT(accessid))'); $this->db->from('accesslog'); $this->db->where('record =','123'); $query=$this->db->get(); return $query->num_rows(); }