CodeIgniter Forums
JOIN whit active record, 3 tables + pagination.. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: JOIN whit active record, 3 tables + pagination.. (/showthread.php?tid=26893)



JOIN whit active record, 3 tables + pagination.. - El Forum - 01-26-2010

[eluser]tnathos[/eluser]
HI.. how i can make this query whit Active record.. and i need put tha pagination..


Code:
select a.titulo, b.marca, sum(c.puntos) as puntos
from
table1 a,
table2 b,
table3 c
where
a.marca=b.id and
a.id_proceso=c.id_proceso and
a.estado =1
group by
a.titulo, b.marca
order by puntos DESC
LIMIT 10, 5



JOIN whit active record, 3 tables + pagination.. - El Forum - 01-26-2010

[eluser]tnathos[/eluser]
any!?


JOIN whit active record, 3 tables + pagination.. - El Forum - 01-26-2010

[eluser]flaky[/eluser]
Read the user guide

Code:
$this->db->select('a.titulo, b.marca, SUM(c.puntos)');
$this->db->from('table1 AS a');
$this->db->join('table2 AS b', 'a.marca = b.id');
$this->db->join('table AS c', 'a.id_proceso = c.id_proceso');
$this->db->where('a.estado', '1');
$this->db->group_by('a.titulo, b.marca');
$this->db->order_by('puntos');
$this->db->limit(10, 5);