0
How to create a function that brings the same query result below using codeigniter?
SELECT AC.cod_setor,AC.cod_coletor ,SUM(ac.quantidade) AS quantidade
FROM item_inventarios AC
INNER JOIN ( SELECT cod_setor , SUM(quantidade) AS quantidade FROM item_inventarios GROUP BY cod_setor HAVING COUNT(distinct cod_setor + cod_coletor) > 1 ) AC2 ON AC2.cod_setor = AC.cod_setor
where `id_inventario`='37'
GROUP BY AC.cod_setor , AC.cod_coletor
wouldn’t be because the
\
id_inventario`` is in quotes (and is considered a string)?– rLinhares
rLinhares, in the example I posted this way, but in the codeigniter it will look like this; ->get_where("item_inventarios", array( "id_inventario"=> $id ))->result_array();
– Hugo Rutemberg