How to add union all in codeigniter datatables query?
<p>I am using codeigniter 2.1 version.In this i have try to write data tables query with union all.I need both query values.But it not working,my query is given below,</p>

<pre><code>$this-&gt;load-&gt;library('datatables');
$this-&gt;datatables-&gt;query("select sales.id as id, sales.date, sales.customer_name, sale_items.product_name, sales.depositcard_amt from sales join sale_items on sale_items.sale_id=sales.id where sales.customer_id = $user and sales.branch_id=$branchid and sales.depositcard_amt != 0.00 UNION ALL select deposit.credit_on, deposit_details.customer_name, deposit_details.package_name, deposit.total_amount from deposit join deposit_details on deposit_details.deposit_id=deposit.id where deposit.customers=$user");
        $this-&gt;datatables-&gt;add_column("Actions", 
            "&lt;center&gt;&lt;/center&gt;", "id")
        -&gt;unset_column('id');
       echo $this-&gt;datatables-&gt;generate();
</code></pre>

<p>Now i have corrected the union all issues, but it not working in datatables. But when i check directly in sql it is working.</p>

<pre><code>$this-&gt;datatables-&gt;query("select sales.id as id, sales.date as date, sales.customer_name, sale_items.product_name as pname, sales.depositcard_amt as debit, 0 as credit from sales join sale_items on sale_items.sale_id=sales.id where sales.customer_id = $user and sales.branch_id=$branchid and sales.depositcard_amt != 0.00 group by sales.id UNION ALL select deposit.id as id, deposit.credit_on as date, deposit_details.customer_name, deposit_details.package_name as pname, 0 as debit, deposit.total_amount as credit from deposit join deposit_details on deposit_details.deposit_id=deposit.id where deposit.customers=$user");
</code></pre>

<p>Please give any suggestion to me. Thanks in advance.</p>