CodeIgniter Forums

Full Version: distinct statement
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]jparent[/eluser]
Hi I have this code:

Code:
$this->db->select("'field'");
$this->db->like('username',$user);
$this->db->group_by('field');
$obj = $this->db->get('sometable');
return $obj->result();

I want to know if there is some way to do somethink like:

Code:
$this->db->select("disticnt 'field'");
$this->db->like('username',$user);
$this->db->group_by('field');
$obj = $this->db->get('sometable');
return $obj->result();

because this code give me an error because it puts "select 'distinct' 'field' from..."
and gives me an error like: "'distinct' is not a field"

How I can do that? I think use the group_by can simulate the distinct clause. I don't know certainly.

El Forum

[eluser]davidbehler[/eluser]
Code:
$this->db->distinct();

El Forum

[eluser]jparent[/eluser]
thanks! I can't belive I don't see it in the documentation. It was in front my nose! Silly of me!