• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with long SQL query

#2
[eluser]WanWizard[/eluser]
Something like:
Code:
$this->db->select('v.answer_id, a.answer');
$this->db->select('COUNT(v.id) AS NumVotes', FALSE);
$this->db->join('poll_answers a', 'a.id = v.answer_id');
$this->db->where('v.poll_id', $poll_id);
$this->db->group_by('a.answer');
$this->db->order_by('NumVotes', 'DESC');
$query = $this->db->get('poll_votes v');

Shouldn't be to difficult, after reading the AR section in the manual...


Messages In This Thread
Help with long SQL query - by El Forum - 06-24-2010, 08:55 AM
Help with long SQL query - by El Forum - 06-24-2010, 09:49 AM
Help with long SQL query - by El Forum - 06-24-2010, 12:00 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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