库存数据库计算当前库存水平2个表的总和并减去 [英] Stock Database working out current stocking level sum of 2 tables and subtract

查看:60
本文介绍了库存数据库计算当前库存水平2个表的总和并减去的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为仓库设置库存数据库我有3张桌子 -

tblproduct

tblproduct

tbl product out

与产品ID的关系


我正在尝试设置查询,以计算当前的库存水平。因此必须展示产品,产品和产品ID。下面是SQL编码,但它不起作用......

I''m setting up stock database for warehouse I''ve got 3 tables-
tblproduct
tblproduct in
tbl product out
Relationship is done with Product ID

I''m trying to set up query, to working out current stock levels. So has to show product in, product out and product ID. Below is SQL coding but it doesn''t work...

展开 | 选择 | Wrap | 行号

推荐答案

你需要据我所知,使用单向连接。如果您的产品没有任何内容,您将获得0结果,因为您使用内部联接。


您应该将产品IN加入您的产品并离开加入您的产品OUT到您的产品。产品输入和产品输出不应该连接在一起。
You need to use 1-way joins as far as I can tell. If you have a product where nothing has come in, you would get 0 results because you use an inner join.

You should Left join the Product IN to your Product and left join your Product OUT to your product. The Product In and Product Out should not be joined together.


Erm抱歉生锈的访问!!我试过下面的代码
Erm sorry bit rusty with access!! i''ve tried code below
展开 | 选择 | Wrap | 行号


笑脸是非常正确的(当然)。生成的SQL应该类似于:
Smiley is quite correct (of course). The resultant SQL should look something like :
展开 | 选择 | Wrap | 行号


这篇关于库存数据库计算当前库存水平2个表的总和并减去的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆