Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我想取总量小于等于零的产品_Php_Mysql - Fatal编程技术网

Php 我想取总量小于等于零的产品

Php 我想取总量小于等于零的产品,php,mysql,Php,Mysql,我已经编写了一个查询(参见图),其中显示了下图所示的结果 现在,我想显示那些产品列表,它们的总可用数量小于或等于零 我使用以下公式计算总可用量- (SUM(credit_quantity) - SUM(debit_quantity)) 请检查如图所示的数据库表结构: 尝试此查询:- SELECT * FROM nrk_product AS np LEFT JOIN nrk_stock AS ns ON np.id = ns.product_id GROUP BY np.id HAVING

我已经编写了一个查询(参见图),其中显示了下图所示的结果

现在,我想
显示那些
产品
列表,它们的总可用
数量
小于或等于零

我使用以下公式计算总可用量-

(SUM(credit_quantity) - SUM(debit_quantity))
请检查如图所示的数据库表结构:

尝试此查询:-

SELECT * FROM nrk_product AS np LEFT JOIN 
nrk_stock AS ns ON np.id = ns.product_id GROUP BY np.id 
HAVING (SUM(ns.credit_quantity) - SUM(ns.debit_quantity)) <= 0 
从nrk_产品中选择*作为np左连接
np.id上作为ns的nrk_库存=np.id上的ns.product_id组

您的图像丢失了(SUM(ns.credit_quantity)-SUM(ns.debit_quantity))您有代码显示吗?您的“following query”丢失了,我看不到“following query”,只是一个公式。我也看不到图像。为什么不能创建一个小提琴而不是添加一张图片?上面的Sql查询给我一个空白结果。请检查小提琴-它不会给出空白结果。