【发布时间】:2023-03-20 19:25:01
【问题描述】:
我的选择查询的现有代码
表命名材料:
mat_id mat_name supplier_id stock_in stock_released Balance date
1 alloy 4 30 0 30 feb13
2 steel 2 15 0 15 feb13
3 alloy 2 0 3 15 feb14
SELECT m.`mat_id`, m.`mat_name`, m.`stock_in`, m.`stock_released`,
(select sum(stock_in) - sum(stock_released)
from material m2
where m2.mat_name = m.mat_name and
m2.mat_id <= m.mat_id
) as balance,
m.`date`
FROM `material` m
ORDER BY m.`mat_id` ASC;
如何在我的查询中添加供应商表中的供应商名称?如何加入?
sup_id sup_name
2 rain
4 george
【问题讨论】: