我正在准备一个HTML表,它将连接2个表。
我无法找出查询,该查询将显示条件为=“ issued and group by item。”的发出的数量的总和。
$results= mysqli_query($db,
"SELECT r.id,
COALESCE(w.sum_requested_qty,0) as sum_requested_qty,
w.sum_issued_qty,
r.stock -COALESCE(w.sum_requested_qty,0) as available_inv FROM rizal_inv r
left join
(select item_id, sum(IFNULL(requested_qty,0)) as sum_requested_qty ,
(SELECT SUM(IFNULL(requested_qty,0)) FROM wmr_items WHERE issuance_status ='issued' ) as sum_issued_qty from wmr_items group by item) w on r.id = w.item_id where r.stock > 0 ORDER BY ABS(r.id);
");
此代码不起作用:
(SELECT SUM(IFNULL(requested_qty,0)) FROM wmr_items
WHERE issuance_status ='issued' ) as sum_issued_qty from wmr_items group by item)
它显示
mysqli_query():(21000/1242):子查询返回多于1行