MySQl query term abbreviation

128
September 07, 2018, at 1:20 PM

I want to collect two different tablodas from different values. This process takes too long because the number of records is too large How can I speed up the query?

Table 1 :sf_uretim10

Table 2 :sf_urun10

<?php 
$query = $db->get_results("SELECT uretimid,urunadi,uretimharid,urunid,cariid,paketsayisi,boy,tonaj,pakettipi,uretimtipi,uretimyeri FROM sf_uretim10 WHERE (durumu='Siparis' OR durumu='URETIMDE') AND cariid > 4  AND sil !=2 ORDER BY urunadi ASC");
?>
<table id="example"> 
    <thead> 
        <tr> 
            <th>Name</th>
            <th>Total A</th>
            <th>Total B</th>
            <th>Total C</th> 
        </tr> 
    </thead> 
    <tbody> 
<?php 
foreach ($query as $row ){
        $total_a = $db->get_var("SELECT SUM(tonaj) FROM sf_urun10 WHERE urunid='$row->urunid' AND tonaj='$tonaj' AND boy='$row->boy' AND (durumu='GIRIS' OR durumu='HATALI') AND cariid < 4 AND sil !=2");
        $total_b = $db->get_var("SELECT SUM(tonaj) FROM sf_urun10 WHERE uretimharid='$row->uretimharid' AND cariid='$row->cariid'  AND (durumu='GIRIS' OR durumu='HATALI') AND sil !=2 ");
        $total_b = $db->get_var("SELECT SUM(tonaj) FROM sf_urun10 WHERE uretimharid='$row->uretimharid' AND cariid='$row->cariid'  AND (durumu='CIKIS') AND sil !=2 ");
?>      
        <tr> 
            <td><?php echo $row->urunadi; ?></td>
            <td><?php echo $total_a; ?></td>
            <td><?php echo $total_b; ?></td>
            <td><?php echo $total_c; ?></td> 
        </tr> 
<?php  }  ?>
    </tbody>

Thank You

Rent Charter Buses Company
READ ALSO
Queries in query set group in to one query using Django

Queries in query set group in to one query using Django

I have a query set like the below

147
The first html row is not being displayed (PHP &amp; MYSQL)

The first html row is not being displayed (PHP & MYSQL)

So, let’s say I have 10 rows in my databaseHowever, after the mysql query, only 9 rows are being displayed in the html table

111
How to show original data in databases

How to show original data in databases

i want to show count result for every my table based on real time date

119