Mysql 两张表 某个字段值相减方法如下


SELECT
(
(SELECT SUM(in_amount) FROM stock_in WHERE company_id=30044 AND is_deleted=0 )
 -
(SELECT SUM(out_amount) FROM stock_out WHERE company_id=30044 AND is_deleted=0)
)as "贮存量结果"

你可能感兴趣的:(mysql,数据库,database)