三表
table rd ID,部门,类别 (主表)
table rds ID,AUTOID,料号,数量,成本ID (从表,与主表ID关联)
table base 部门,料号,成本ID更新RDS.成本ID=base.成本ID
当 base.部门=rd.部门 and rd.类别='入库' and base.料号=rds.料号
table rd ID,部门,类别 (主表)
table rds ID,AUTOID,料号,数量,成本ID (从表,与主表ID关联)
table base 部门,料号,成本ID更新RDS.成本ID=base.成本ID
当 base.部门=rd.部门 and rd.类别='入库' and base.料号=rds.料号
where a.料号=b.料号 and a.id=c.id and b.部门=c.部门 and c.类别='入库'
set 成本id=base.成本id
from rds,rd,base
where base.部门=rd.部门 and rd.类别='入库' and base.料号=rds.料号
set 成本id=base.成本id
from rds a ,rd b,base c
where c.部门=b.部门 and b.类别='入库' and c.料号=a.料号
set
成本ID=b.成本ID
from
RDS a join base b
on a.料号=b.料号
join rd c
on a.id=c.id and b.部门=c.部门
where
c.类别='入库'
因为一楼的写法,就是内连接 inner join 的另一种写法,但是好象新的标准是4楼的写法。
where a.料号=b.料号 and a.id=c.id and b.部门=c.部门 and c.类别='入库'