您好我编辑了我的问题
有4个表
1 | lal
2 | sobuj
id |成员名称|团队|
1 | SAGOR | 1 |
2 |守门| 1 |
1 | 1 | 1 | 100 | 12 | 2016-09-01 |
2 | 2 | 1 | 120 | 34 | 2016-09-01 |
3 | 1 | 1 | 130 | 22 | 2016-09-01 |
4 | 3 | 1 | 120 | 0 | 2016-09-01 |
和
1 | 1 | 1 | 100 | 12 | 2016-09-01 |
2 | 2 | 1 | 120 | 34 | 2016-09-01 |
3 | 1 | 1 | 130 | 22 | 2016-09-01 |
$result=mysql_query(select * from member where team='1');
$row=mysql_fetch_array($result);
do{
$aresult=mysql_query(select sum(deposit)-sum(refund)as balance from dps where member='$row[id]');
$arow=mysql_fetch_array($aresult);
echo $arow[balance];
$bresult=mysql_query(select sum(mvs_total)as mvs_balance from mvs where member='$row[id]' and date1<='2016-09-01');
$brow=mysql_fetch_array($bresult);
}while($row=mysql_fetch_array($result));
它花了太多时间
如何避免子查询或如何节省时间
建议PLZ
提前致谢
答案 0 :(得分:0)
试试这个,
select sum(deposit)-sum(refund) from dps JOIN member ON (dps. member = member.id) WHERE team='1';