我有这个查询字符串...
select i.invoiceid, i.date, i.total, i.total - (select ifnull(sum(p.amount), 0) from payment p where p.invoice = i.invoiceid) as remainingbalance
from invoice i inner join client c
on i.client = c.clientid
where i.isdeleted = 0 and i.client = 1
union
select p.paymentid, p.date, p.invoice, p.amount from payment p inner join invoice i
on i.invoiceid = p.invoice
inner join paymenttype
on paymenttype.paymenttypeid = p.paymenttypeid
inner join client c
on c.clientid = i.client
where c.clientid = 1
and i.isdeleted = 0
order by date
当我尝试这个...
<?php
echo $clientArrayInvoice[1]['paymentid'];
?>
当我在 $clientArrayInvoice 上执行 print_r 时没有得到任何结果
Array ( [0] => Array ( [invoiceid] => 1 [date] => 2012-04-12 [total] => 602.29 [remainingbalance] => 300.96 ) [1] => Array ( [invoiceid] => 1 [date] => 2012-04-27 [total] => 1.00 [remainingbalance] => 301.33 ) )
我理解它为什么这样做,但是我如何让列说paymentid
而不是invoiceid
返回结果。所以我可以确定什么是 apaymentid
什么是 ainvoiceid
我希望这是有道理的。