1
I’m doing a db search that needs to resume the sum of a field and the last corresponding value, and grouping them to an index
Query
$stmt = getConn()->query("SELECT senha,movi,SUM(entrada) as entrada,custo FROM estoquemovimento ORDER BY id DESC");
$items = $stmt->fetchAll(PDO::FETCH_GROUP | PDO::FETCH_ASSOC | PDO::FETCH_UNIQUE);
Answer
Array
(
[NbpsCQAMyc] => Array
(
[movi] => Adicionado
[entrada] => 2.000
[custo] => 3.00
)
)
is all correct, in the array formatting, only the cost is searching for the first record, and not the last record
I need the search to return the cost related to the last record
uses LIMIT 1, so it only takes one record
– Tmc
even with LIMIT 1, returns the cost for the first record
– Willian
yes, pq cost and the current value of the last purchase, is input and all the weight that entered
– Willian