Hallo Zusammen,
leider bin ich ein totaler Neuling in Bezug auf Datenbankebene.
Ich versuche schon seit Tagen meinen Filter anzupassen jedoch leider ohne Erfolg.
$sql = "SELECT countries.name as "LAND", countries.area, avg(country_stats.gdp) AS BIP, avg(country_stats.population) AS POPULATION, continents.name AS KONTINENT
FROM countries, country_stats, regions INNER JOIN continents
ON
regions.continent_id = continents.continent_id
WHERE regions.region_id = countries.region_id GROUP BY countries.country_id ORDER BY countries.name;"
Hiermit listet er mir alle Länder auf berechnet jedoch nicht mehr korrekt die BIP und auch nicht mehr korrekt die POPULATION.
Passe ich jedoch die Struktur an und ergänze den Befehl wie folgt:
$sql = "SELECT countries.name as "LAND", countries.area, avg(country_stats.gdp) AS BIP, avg(country_stats.population) AS POPULATION, continents.name AS KONTINENT
FROM countries, country_stats, regions INNER JOIN continents
ON
regions.continent_id = continents.continent_id
WHERE regions.region_id = countries.region_id AND regions.name = "'. $region .'" AND countries.country_id = country_stats.country_id GROUP BY countries.country_id ORDER BY countries.name';
Dann bekomme ich zwar die BIP und Population korrekt angezeigt, jedoch nicht mehr alle Länder.
Ich weiß auch woran das Problem liegt, da in der Tabelle country_stats manche country_id's fehlen. Hier wäre es toll, dass diese dann trotzdem aufgelistet sind jedoch in der Spalte BIP und POPULATION als Nullwert angezeigt werden.
Es wäre super nett von euch, wenn ihr mir ein Tipp geben könntet wie ich auf die Lösung komme.
Vielleicht liege ich auch ganz falsch.
Liebe Grüße und vielen Dank Scout1991
leider bin ich ein totaler Neuling in Bezug auf Datenbankebene.
Ich versuche schon seit Tagen meinen Filter anzupassen jedoch leider ohne Erfolg.
$sql = "SELECT countries.name as "LAND", countries.area, avg(country_stats.gdp) AS BIP, avg(country_stats.population) AS POPULATION, continents.name AS KONTINENT
FROM countries, country_stats, regions INNER JOIN continents
ON
regions.continent_id = continents.continent_id
WHERE regions.region_id = countries.region_id GROUP BY countries.country_id ORDER BY countries.name;"
Hiermit listet er mir alle Länder auf berechnet jedoch nicht mehr korrekt die BIP und auch nicht mehr korrekt die POPULATION.
Passe ich jedoch die Struktur an und ergänze den Befehl wie folgt:
$sql = "SELECT countries.name as "LAND", countries.area, avg(country_stats.gdp) AS BIP, avg(country_stats.population) AS POPULATION, continents.name AS KONTINENT
FROM countries, country_stats, regions INNER JOIN continents
ON
regions.continent_id = continents.continent_id
WHERE regions.region_id = countries.region_id AND regions.name = "'. $region .'" AND countries.country_id = country_stats.country_id GROUP BY countries.country_id ORDER BY countries.name';
Dann bekomme ich zwar die BIP und Population korrekt angezeigt, jedoch nicht mehr alle Länder.
Ich weiß auch woran das Problem liegt, da in der Tabelle country_stats manche country_id's fehlen. Hier wäre es toll, dass diese dann trotzdem aufgelistet sind jedoch in der Spalte BIP und POPULATION als Nullwert angezeigt werden.
Es wäre super nett von euch, wenn ihr mir ein Tipp geben könntet wie ich auf die Lösung komme.
Vielleicht liege ich auch ganz falsch.
Liebe Grüße und vielen Dank Scout1991
Kommentar