分别对几个表依次求和

SELECT sum(windowsales),sum(weixinsales),sum(machinesales),sum(othersales) FROM db_name

按照条件对所有表求总和

SELECT sum(windowsales+weixinsales+machinesales+othersales) as zonghe FROM db_name WHERE test='$test'

通过as后面的zonghe可以获取前面所有表的总和数
$test 为条件

最后修改:2015 年 11 月 19 日
如果觉得我的文章对你有用,请随意赞赏