简体   繁体   English

计算两个MySQL表之间的数量

[英]Calculate amount between two MySQL tables

I have two tables one for incoming goods and inventory and another for the exit of products. 我有两个表,一个用于进货和库存,另一个用于产品出口。

How do I do a select in mysql to return the amount available in stock without using PHP. 我如何在mysql中进行选择以返回不使用PHP的可用库存量。

In the case would STOCK - OUTPUTS. 在这种情况下将有现货-输出。

Thanks! 谢谢!

I think you want something like this: 我想你想要这样的东西:

SELECT 
(SELECT SUM(quantity) FROM stock) - 
(SELECT SUM(quantity) FROM outputs) AS 'slo'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM