Is het mogenlijk al deze SQL statements te herschrijven als 1 statement te herscrhijven.
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| $sqlString = "SELECT DISTINCT article_number FROM shop_product"; $sql->Query($sqlString); print("<table>"); while ($sql->ReadRow()) { $id = $sql->RowData[0]; $sql2->Query("SELECT ROUND(SUM(price),2) FROM shop_order WHERE article_number = '$id' AND currency='euro'"); print("<tr>"); if($sql2->ReadRow()) { print("<td>" .$sql2->RowData[0] ."</td>"); } $sql2->Query("SELECT ROUND(SUM(price),2) FROM shop_order WHERE article_number = '$id' AND currency='dollar'"); if($sql2->ReadRow()) { print("<td>" .$sql2->RowData[0] ."</td>"); } print("</tr>"); } print("</table>"); |