我有一个使用MySQL使用CodeIgniter生成的数据集。我需要在视图页面中获取交付的总数量。为此,我使用了以下代码。
<?php $delivered_qty_total += $row->quantity; endforeach; ?>
<?php endif; ?>
但是它并没有给出交付数量的准确总数。我正在使用
GROUP_CONCAT
和SEPARATOR "<br />"
传递数据。当我使用tbl_order_products.quantity
而不是GROUP_CONCAT
时,它会给我准确的总数。但是我需要GROUP_CONCAT
。'GROUP_CONCAT(tbl_order_products.quantity SEPARATOR "<br />" ) as quantity ',
最佳答案
将此添加到您的查询:
SUM(tbl_order_product.quantity) AS quantity_total
See this demo举例说明我如何看待您。