我有代码:
$balanceModelCredit = new Model_BalanceCredit();
$balanceModelDebt = new Model_BalanceDebt();
$selectQueryDebt = $balanceModelDebt->select()
->from('balance_debt', array('date',
'amount',
'description',
new Zend_Db_Expr('"koszta"')
));
$selectQueryDebt->where('balance_id=?', $balance_id);
$selectQueryCredit = $balanceModelCredit->select()
->from('balance_credit', array('date',
'amount',
'description',
new Zend_Db_Expr('"przychod"')
));
$selectQueryCredit->where('balance_id=?', $balance_id);
如何进行UNION声明?
答案 0 :(得分:0)
你只需要这样做:
$selectQueryCredit->where('balance_id = ?', $balance_id);
$selectQueryCredit->union(array($selectQueryDebt));
希望它有所帮助。