我想从不同的值中收集两个不同的tabloda。这个过程花费的时间太长,因为记录的数量太多。我如何加快查询速度?
表1:sf\U时间10
表2:sf\ U 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>
谢谢您
暂无答案!
目前还没有任何答案,快来回答吧!