查询
$sql = "SELECT DISTINCT
IPH.op_code,
debt_trans.tx_amount as cash,
DT.tx_amount as revenue
FROM debt_trans
LEFT JOIN debt_trans DT ON DT.debt_code=debt_trans.debt_code AND DT.tx_date=debt_trans.tx_date AND DT.tx_time=debt_trans.tx_time
LEFT JOIN instplan IP ON IP.debt_code=debt_trans.debt_code AND IP.ipactualpaymentdt=debt_trans.tx_date
LEFT JOIN instplanheader IPH ON IPH.debt_code=debt_trans.debt_code AND IPH.ipplanid=IP.ipplanid
AND debt_trans.tran_code NOT IN ('DR3001','DR3002','DR3003','DR3004','RP1800','CC5000')
AND debt_trans.tx_amount > 0.00
AND debt_trans.tx_date >= '2019-02-04' AND debt_trans.tx_date <= '2019-02-04'
AND IPH.op_code = IP.op_code
AND DT.tran_code IN ('CC5000')
AND DT.tx_amount > 0.00
AND DT.tx_date >= '2019-02-04' AND DT.tx_date <= '2019-02-04'
";
结果
Array
( [0] =>数组 ( [op_code] => DOMP [现金] => 5.00 [收入] => 2.25 )
[1] => Array
(
[op_code] => DOMP
[cash] => 671.00
[revenue] => 301.95
)
[2] => Array
(
[op_code] => RHYSL
[cash] => 5.00
[revenue] => 2.25
)
[3] => Array
(
[op_code] => RHYSL
[cash] => 671.00
[revenue] => 301.95
)
)
尝试获取
Row Count : 2
数组 ( [0] =>数组 ( [op_code] => DOMP [现金] => 5.00 [收入] => 2.25 )
[1] => Array
(
[op_code] => DOMP
[cash] => 671.00
[revenue] => 301.95
)
必须仍然在做一些错误的事情。请有人帮忙。我添加了更多的联接。因为最终结果中我需要它们。