mysql_query(conn,"create table 入库单表 \
( \
单号 Text, \
入库日期 DateTime, \
品名 Text, \
供货商编号 Text, \
颜色 Text, \
规格 Text, \
数量 int, \
单位 Text, \
单价 double, \
金额 double \
)" \
); mysql_query(conn,"create table 出库单表 \
( \
单号 Text, \
出库日期 DateTime, \
品名 Text, \
供货商编号 Text, \
颜色 Text, \
规格 Text, \
数量 int, \
单位 Text, \
单价 double, \
金额 double, \
领用人 Text, \
车间 Text, \
班主 Text \
)" \
);
( \
单号 Text, \
入库日期 DateTime, \
品名 Text, \
供货商编号 Text, \
颜色 Text, \
规格 Text, \
数量 int, \
单位 Text, \
单价 double, \
金额 double \
)" \
); mysql_query(conn,"create table 出库单表 \
( \
单号 Text, \
出库日期 DateTime, \
品名 Text, \
供货商编号 Text, \
颜色 Text, \
规格 Text, \
数量 int, \
单位 Text, \
单价 double, \
金额 double, \
领用人 Text, \
车间 Text, \
班主 Text \
)" \
);
单号 int,
入库日期 DateTime,
品名 varchar(10),
供货商编号 int,
颜色 varchar(10),
规格 varchar(10),
数量 int,
单位 varchar(10),
单价 varchar(10),
金额 varchar(10)
)
select 品名,数量 from 入库单表
union all
select 品名,数量 from 出库单表
) t
group by 品名
select 品名,(count(a.数量)-count(b.数量)) as 库存量
from 入库表单 a join 出库表单 on 入库表单.品名=出库表单.品名
group by 品名
select a.品名,(sum(a.数量)-sum(b.数量)) as 库存量
from 入库表单 a join 出库表单 b on a.品名=b.品名
group by a.品名