Hallo zusammen,
ich stecke gerade fest und komme nicht weiter...
Entwicklungsumgebung MySQL & PHP
Ich habe drei Tabellen:
Tabelle 1 (logo_firma):
li_id | li_name
Tabelle 2 (logo_form):
id | id_firma | hotelbeschreibung
Tabelle 3 (logo_leistungen):
id_firma | leistung
Die sind so gefüllt:
Tabelle 1 (logo_firma):
| 17 | Hotel Krone |
| 18 | Hotel am See |
Tabelle 2 (logo_form):
| 1 | 17 | Gasthof m. Pool |
| 2 | 18 | Direkt am See |
Tabelle 3 (logo_leistungen):
| 17 | sauna |
| 17 | pool |
| 17 | whirlpool |
| 18 | sauna |
| 18 | bootsausflüge |
| 18 | fitnessraum |
Jetzt will ich mit Join und Select alle ausgeben:
17 (id_firma) | Hotel Krone (li_name) | Gasthof m. Pool (hotelbeschreibung) | sauna, pool, whirlpool (leistung)
18 (id_firma) | Hotel am See (li_name) | Direkt am See (hotelbeschreibung) | sauna, bootsausflüge, fitnessraum (leistung)
Dazu habe ich folgendes ausprobiert:
SELECT
t1.id_firma,
li_name,
leistung,
id,
hotelbeschreibung
FROM (logo_form AS t1
INNER JOIN logo_leistungen AS t2
ON t1.id_firma = t2.id_firma)
INNER JOIN logo_firma
ON t1.id_firma = logo_firma.li_id
SQL liefert mir dann folgendes:
17 | Hotel Krone | sauna | Gasthof m. Pool|
17 | Hotel Krone | pool | Gasthof m. Pool|
17 | Hotel Krone | whirlpool | Gasthof m. Pool|
18 | Hotel am See | sauna | Gasthof m. Pool|
18 | Hotel am See | bootsausflüge | Gasthof m. Pool|
18 | Hotel am See | fittnessraum | Gasthof m. Pool|
Frage:
Ich möchte nicht für jede Leistung das Hotel entsprechend ausgeben sondern das hotel auf der Webseite mit allen Leistungen anzeigen:
17 | Hotel Krone | sauna, pool, whirlpool | Gasthof m. Pool|
18 | Hotel am See | sauna,bootsausflüge,fittnessraum | Gasthof m. Pool|
Wie gehe ich da vor?
Grüße von Guma