php - Code Igniter subquery with Active record -


I'm trying to query this in code ignition:

  select items Itoifsing.Marca, items_mtoedifsing.Modelo, items_mtoedifsing.Familia, items_movimientos.id_item, items_movimientos.Tipo_Movimiento, items_movimientos.Fecha_Movimiento, items_movimientos.Destino join items_mtoedifsing on items_mtoedifsing.id_item from items_movimientos = items_movimientos.id_item where items_movimientos.fecha_movimiento = (max (the items_movimientos fecha_movimiento) Select it where it.id_item = items_movimientos.id_item) and items_movimientos.Destino = 'value'   

but I'm having some issues with the subquery. This is my code that returns 0 rows when 1 row comes back:

 Select  $ this-> db-> ('*'); $ This- & gt; Db- & gt; ('items_movimientos'); $ This- & gt; Db- & gt; Join ('items_mtoedifsing', 'items_mtoedifsing.id_item = items_movimientos.id_item'); $ This- & gt; Db- & gt; Where ('items_movimientos.Fecha_Movimiento', 'Select the maximum of items (fecha_movimiento) from the item where it.id_item = items_movimientos.id_item)'); $ This- & gt; Db- & gt; Where ('items_movimientos.Destino', $ Ultimate);   

What can I do with this part:

  $ this-> Db- & gt; Where ('items_movimientos.Fecha_Movimiento', '(select maximum (fecha_movimiento) from items_movimientos where it.id_item = items_movimientos.id_item)');  

By passing the second parameter as null and in the form of a third parameter, As the wrong one can use.

  $ subquery = "(Select the item's maximum (fade_momimiento) items_mozentos from where it is .id_item = items_movimientos.id_item)"; $ This- & gt; Db- & gt; Where ('items_movimientos.fecha_Movimiento ='. $ Subquery, null, FALSE);    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -