Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL execution being so slow on my case
    text
    copied!<p>I have a problem about my code, this is my code on connecting to database, selecting some unique data and sum on these unique data from another table, nothing problem with my code, thats all okay, but it taking so long time on querying.</p> <pre><code>&lt;?php include "koneksi.php"; $no=1; $arqury=odbc_exec($koneksi, "SELECT DISTINCT NIP_AR,NAMA_AR FROM USRBPS.MASTERFILE"); while($ar=odbc_fetch_array($arqury)){ $total=0; $ambilqury=odbc_exec($koneksi, "SELECT NPWP FROM USRBPS.MASTERFILE WHERE NIP_AR='$ar[NIP_AR]'"); while($ambil=odbc_fetch_array($ambilqury)){ $testqury=mysql_query("SELECT SUM(jumlah_bayar) as PENERIMAAN FROM mpnruteng WHERE npwp='$ambil[NPWP]'"); $test=mysql_fetch_array($testqury); $total += $test[PENERIMAAN]; } if($ar[NIP_AR]==""){ echo "&lt;tr&gt;&lt;td&gt;$no&lt;/td&gt;&lt;td colspan=2&gt;UNASSIGN&lt;/td&gt;&lt;td&gt;$total&lt;/td&gt;"; } else{ echo "&lt;tr&gt;&lt;td&gt;$no&lt;/td&gt;&lt;td&gt;$ar[NAMA_AR]&lt;/td&gt;&lt;td&gt;$ar[NIP_AR]&lt;/td&gt;&lt;td&gt;$total&lt;/td&gt;&lt;/tr&gt;"; } $no++; } ?&gt; </code></pre> <p>on simply is being like this,</p> <pre><code>|Name |num_se --------------- |andre |1111 |john |2222 |simon |3333 |andre |4444 |andre |5555 |simon |6666 |john |7777 |num_se |Total --------------- |1111 |12 |2222 |15 |3333 |10 |4444 |8 |5555 |20 |6666 |18 |7777 |22 </code></pre> <p>So, what i need is get the sum of 'Total', from each 'Name'. What i want to get is, list of the name "Uniquely" (in this example is Andre, John, and Simon) with each sum of "Total" that get from num_se.</p> <p>sorry my english is bad, but i hope you're understand.</p>
 

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