Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It would have been pertinent to explain you were working against two separate data sources up front.</p> <p>It's slow because you're attempting to loop over your resultsets in PHP, calling individual queries to return single rows from another table, which is very inefficient.</p> <p>Let the database handle the relationship between your two related tables by using a <code>JOIN</code> , and then let it handle to aggregation of your grand total, not just the individual totals.</p> <p>The following query will get your total for each distinct pair of nip_ar and nama_ar:</p> <pre><code>SELECT t1.NIP_AR, t1.NAMA_AR, SUM(t2.jumlah_bayar) as PENERIMAAN FROM USRBPS.MASTERFILE t1 INNER JOIN mpnruteng t2 ON t2.npwp = t1.npwp GROUP BY 1, 2 </code></pre> <p>But you're rolling this up into one grand <code>$total</code> anyhow, so this will get that for you:</p> <pre><code>SELECT SUM(PENERIMAAN) as PENERIMAAN FROM ( SELECT t1.NIP_AR, t1.NAMA_AR, SUM(t2.jumlah_bayar) as PENERIMAAN FROM USRBPS.MASTERFILE t1 INNER JOIN mpnruteng t2 ON t2.npwp = t1.npwp GROUP BY 1, 2 ) </code></pre> <p>You can configure a link to your mySql server from your Oracles server. Refer to <a href="http://docs.oracle.com/cd/B19306_01/server.102/b14232/admin.htm#sthref152" rel="nofollow">Using Heterogenous Service Agents - chapter 4. Setting up access to non-Oracle systems</a>. My understanding is that you cannot link to Oracle from mySql.</p> <p>This will allow you to run the above queries, on your Oracle instance. Although you'll need to update your table names to fully qualify them with the datasource names.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload