Welcome Guest, Not a member yet? Register   Sign In
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



Theme © iAndrew 2016 - Forum software by © MyBB