Jump to content
xt:Commerce Community Forum

MySQL Fehler bei Abfrage nach Bestellungen pro Land


sugar99

Recommended Posts

Ich würde gern eine Karte anzeigen lassen in welchem Land bzw. Kontinent wieviele Bestellungen von einem bestimmten Produkt es gibt. Folgendes Script zeigt mir leider alle Bestellungen von den entsprechenden Ländern an, nicht diese die zu dem Produkt (0001) gehören. Also irgendwie scheint die "WHERE" Abfrage falsch zu sein? Kann mir jemand helfen?

 $query = "SELECT 
DISTINCT COUNT(*) as count, orders.orders_id, orders.customers_country, countries.countries_name, orders_products.products_model

FROM orders

JOIN
orders_products ON orders.orders_id = orders_products.orders_id
JOIN
countries ON orders.customers_country = countries.countries_name
WHERE
countries.countries_name='Andorra' OR countries.countries_name='Austria' OR countries.countries_name='Belgium' OR countries.countries_name='Bosnia and Herzegowina' OR countries.countries_name='Bulgaria' OR countries.countries_name='Denmark' OR countries.countries_name='Germany' OR countries.countries_name='Estonia' OR countries.countries_name='Faroe Islands' OR countries.countries_name='Finland' OR countries.countries_name='France' OR countries.countries_name='Gibraltar' OR countries.countries_name='Greenland' OR countries.countries_name='Greece' OR countries.countries_name='United Kingdom' OR countries.countries_name='Ireland' OR countries.countries_name='Iceland' OR countries.countries_name='Italy' OR countries.countries_name='Croatia' OR countries.countries_name='Latvia' OR countries.countries_name='Liechtenstein' OR countries.countries_name='Lithuania' OR countries.countries_name='Luxembourg' OR countries.countries_name='Malta' OR countries.countries_name='Macedonia' OR countries.countries_name='Moldova' OR countries.countries_name='Monaco' OR countries.countries_name='Netherlands' OR countries.countries_name='Norway' OR countries.countries_name='Poland' OR countries.countries_name='Portugal' OR countries.countries_name='Romania' OR countries.countries_name='San Marino' OR countries.countries_name='Sweden' OR countries.countries_name='Switzerland' OR countries.countries_name='Slovakia' OR countries.countries_name='Slovenia' OR countries.countries_name='Spain' OR countries.countries_name='Turkey' OR countries.countries_name='Czech Republic' OR countries.countries_name='Ukraine' OR countries.countries_name='Hungary' OR countries.countries_name='Cyprus'

AND orders_products.products_model ='0001'

GROUP BY
countries.countries_name";

$result = mysql_query($query) or die("Temporary query failure: " . mysql_error());

echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td width=\"25%\"><img src=\"/images/map_europe.gif\" width=\"246\" height=\"185\" /></td>
<td width=\"75%\">";

echo " <table>\n";
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
echo " <tr>\n";
echo " <td>$row[2]</td>\n";
echo " <td align=\"center\">$row[0]</td>\n";
echo " </tr>\n";
}
echo " </table>\n";
echo " </td>
</tr>
</table>\n";

mysql_free_result($result);[/PHP]

Danke!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
  • Create New...