微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

php-如何在一个查询中完成多个查询

如何在一个查询中完成以下查询,并按照下面的方式获取结果?

// Begining of January

$ob = MysqL_query(" SELECT SUM(salary_amount) AS total FROM teacherexpense WHERE  month(disburse_date)='01' AND  year(disburse_date)='$year' ");
$nt = MysqL_fetch_assoc($ob);
$salaryamount= $nt['total'];


$ob = MysqL_query(" SELECT SUM(other_expense_amount) AS expenseamount FROM otherexpense WHERE month(other_expense_date)='01' AND year(other_expense_date)='$year'  ");
$nt = MysqL_fetch_assoc($ob);
$expenseamount= $nt['expenseamount'];

$jk = MysqL_query(" SELECT SUM(amountpaid) AS revenue FROM studentpayment1 WHERE month(received_date)='01' AND year(received_date)='$year' ");
$t = MysqL_fetch_assoc($jk);
$revenue= $t['revenue'];

$ob = MysqL_query(" SELECT SUM(other_earning_amount) AS otherearningamount FROM otherearning WHERE month(other_earning_date)='01' AND year(other_earning_date)='$year' ");
$nt = MysqL_fetch_assoc($ob);
$otherearningamount= $nt['otherearningamount'];


$January= ($revenue+$otherearningamount)-($salaryamount+$expenseamount);
// End of January

解决方法:

将其填充到存储过程中?
PHP数据库驱动程序不允许您运行多个以;分隔的查询.出于安全原因.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐