• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
distinct statement

#1
[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.

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

#3
[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!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.